001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojava.nbio.survival.kaplanmeier.figure;
022
023/**
024 *
025 * @author willishf@gmail.com
026 */
027public class CensorStatus implements Comparable<CensorStatus> {
028
029        /**
030         *
031         */
032        public String row;
033        /**
034         *
035         */
036        public Double time;
037        /**
038         *
039         */
040        public String censored;
041        /**
042         *
043         */
044        public String group;
045        /**
046         *
047         */
048        public Double value;
049        /**
050         *
051         */
052        public Double zscore;
053        /**
054         *
055         */
056        public Double weight = 1.0; // assume default weight 1.0
057
058
059        private Double percentage = null; //allow the percentage to be set externally for various weighted correction methods.
060        /**
061         *
062         */
063        public Double nevents;
064        /**
065         *
066         */
067        public Double ncens;
068        /**
069         *
070         */
071        public Double nrisk;
072
073        /**
074         *
075         */
076        public CensorStatus() {
077        }
078
079        /**
080         *
081         * @param group
082         * @param time
083         * @param censored
084         */
085        public CensorStatus(String group, Double time, String censored) {
086                this.group = group;
087                this.time = time;
088                this.censored = censored;
089        }
090
091        /**
092         *
093         * @return
094         */
095        public CensorStatus getCopy(){
096                CensorStatus cs = new CensorStatus();
097                cs.row = row;
098                cs.time = time;
099                cs.censored = censored;
100                cs.group = group;
101                cs.value = value;
102                cs.zscore = zscore;
103                return cs;
104        }
105
106        @Override
107        public String toString() {
108                return time + " " + censored + " " + group + " " + row;
109        }
110
111        @Override
112        public int compareTo(CensorStatus o) {
113        //    System.out.println("Comparing " + this + " " + o);
114                if (time == null) {
115                        return -1;
116                }
117                if (o.time == null) {
118                        return 1;
119                }
120
121                if (time < o.time) {
122                        return -1;
123                } else if (time > o.time) {
124                        return 1;
125                } else {
126                        if (censored.equals(o.censored)) {
127                                return 0;
128                        }
129                        if (censored.equals("0")) {
130                                return -1;
131                        } else {
132                                return 1;
133                        }
134                }
135        }
136
137        /**
138         * @return the percentage
139         */
140        public Double getPercentage() {
141                return percentage;
142        }
143
144        /**
145         * @param percentage the percentage to set
146         */
147        public void setPercentage(Double percentage) {
148                this.percentage = percentage;
149        }
150}