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 * created at 20 Feb 2014
021 * Author: ap3
022 */
023
024package org.biojava.nbio.genome.parsers.cytoband;
025
026import java.io.Serializable;
027
028public class Cytoband implements Serializable, Comparable<Cytoband> {
029
030
031         /**
032         *
033         */
034        private static final long serialVersionUID = 2805976387404499650L;
035        String chromosome;
036        Integer start;
037        Integer end;
038        String locus;
039        StainType type;
040
041
042
043        public String getChromosome() {
044                return chromosome;
045        }
046
047
048
049        public void setChromosome(String chromosome) {
050                this.chromosome = chromosome;
051        }
052
053
054
055        public Integer getStart() {
056                return start;
057        }
058
059
060
061        public void setStart(Integer start) {
062                this.start = start;
063        }
064
065
066
067        public Integer getEnd() {
068                return end;
069        }
070
071
072
073        public void setEnd(Integer end) {
074                this.end = end;
075        }
076
077
078
079        public StainType getType() {
080                return type;
081        }
082
083
084
085        public void setType(StainType type) {
086                this.type = type;
087        }
088
089
090
091        @Override
092        public int compareTo(Cytoband o) {
093
094                if ( this.chromosome.equals( o.chromosome)) {
095                        return this.start.compareTo(o.start);
096                } else {
097
098
099
100                        Short s1 = null;
101                        try {
102                                s1 = Short.parseShort(chromosome.substring(3));
103                        } catch (NumberFormatException ex){}
104                        Short s2 = null;
105                        try {
106                                s2 = Short.parseShort(o.chromosome.substring(3));
107                        }catch (NumberFormatException ex){}
108
109                        if (s1 == null || s2 == null){
110                                return this.chromosome.compareTo(o.chromosome);
111                        } else {
112                                return s1.compareTo(s2);
113                        }
114                }
115
116        }
117
118
119
120        public String getLocus() {
121                return locus;
122        }
123
124
125
126        public void setLocus(String locus) {
127                this.locus = locus;
128        }
129
130
131
132        @Override
133        public String toString() {
134                return "Cytoband [chromosome=" + chromosome + ", start=" + start
135                                + ", end=" + end + ", locus=" + locus + ", type=" + type + "]";
136        }
137
138
139
140
141
142
143
144}