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 *
021 * Author: Andreas Prlic
022 *
023 */
024package org.biojava.nbio.structure.domain.pdp;
025
026import javax.xml.bind.annotation.XmlAccessType;
027import javax.xml.bind.annotation.XmlAccessorType;
028import javax.xml.bind.annotation.XmlRootElement;
029import java.io.Serializable;
030import java.util.ArrayList;
031import java.util.List;
032
033@XmlRootElement(name = "Domain", namespace ="http://www.biojava.org")
034@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
035
036/** represents a Domain
037 * @since 3.0.2
038 */
039public class Domain implements Comparable<Domain>, Serializable{
040
041        /**
042         *
043         */
044        private static final long serialVersionUID = -1293994033102271366L;
045
046        String id;
047        int size;
048        int nseg;
049        double score;
050
051        List<Segment>segments = new ArrayList<Segment>();
052
053        public Domain(){
054
055        }
056
057        public String getId() {
058                return id;
059        }
060
061
062
063        public void setId(String id) {
064                this.id = id;
065        }
066
067
068
069        @Override
070        public String toString() {
071                return "Domain [size=" + size + ", nseg=" + nseg + ", score=" + score
072
073                                + "]";
074        }
075
076        public List<Segment> getSegments() {
077
078                return segments;
079        }
080
081        public Segment getSegmentAtPos(int pos){
082                int size = segments.size();
083                while ( pos >= size){
084                        segments.add(new Segment());
085                        size++;
086
087                }
088                return segments.get(pos);
089        }
090
091
092        @Override
093        public int compareTo(Domain other) {
094                if ( this.getId() == null)
095                        return 1;
096                if ( other.getId() == null)
097                        return -1;
098                return this.getId().compareTo(other.getId());
099        }
100
101        public int getSize() {
102                return size;
103        }
104
105        public void setSize(int size) {
106                this.size = size;
107        }
108
109        public int getNseg() {
110                return nseg;
111        }
112
113        public void setNseg(int nseg) {
114                this.nseg = nseg;
115        }
116
117        public double getScore() {
118                return score;
119        }
120
121        public void setScore(double score) {
122                this.score = score;
123        }
124
125        public void setSegments(List<Segment> segments) {
126                this.segments = segments;
127        }
128
129
130
131}
132
133