X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=916d785222d04f1ed7be7375dda8d219a5eee26e;hb=c394157681d10261bd6f7883b19eaf88d6784609;hp=5c1fba5da96a747f3b1bfe763bdcbfe0d13b3541;hpb=be32c14cd8e48fe0a207cd7030cb9cd46f894678;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 5c1fba5..916d785 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -37,7 +37,7 @@ import fr.orsay.lri.varna.models.rna.RNA; * @author $author$ * @version $Revision$ */ -public class Sequence implements SequenceI +public class Sequence extends ASequence implements SequenceI { SequenceI datasetSequence; @@ -51,7 +51,7 @@ public class Sequence implements SequenceI int end; - Vector pdbIds; + Vector pdbIds; String vamsasId; @@ -59,6 +59,7 @@ public class Sequence implements SequenceI RNA rna; + /** * This annotation is displayed below the alignment but the positions are tied * to the residues of this sequence @@ -90,20 +91,30 @@ public class Sequence implements SequenceI */ public Sequence(String name, String sequence, int start, int end) { - this.name = name; - this.sequence = sequence.toCharArray(); - this.start = start; - this.end = end; - parseId(); - checkValidRange(); + initSeqAndName(name, sequence.toCharArray(), start, end); } public Sequence(String name, char[] sequence, int start, int end) { - this.name = name; - this.sequence = sequence; - this.start = start; - this.end = end; + initSeqAndName(name, sequence, start, end); + } + + /** + * Stage 1 constructor - assign name, sequence, and set start and end fields. + * start and end are updated values from name2 if it ends with /start-end + * + * @param name2 + * @param sequence2 + * @param start2 + * @param end2 + */ + protected void initSeqAndName(String name2, char[] sequence2, int start2, + int end2) + { + this.name = name2; + this.sequence = sequence2; + this.start = start2; + this.end = end2; parseId(); checkValidRange(); } @@ -121,7 +132,7 @@ public class Sequence implements SequenceI .println("POSSIBLE IMPLEMENTATION ERROR: null sequence name passed to constructor."); name = ""; } - // Does sequence have the /start-end signiature? + // Does sequence have the /start-end signature? if (limitrx.search(name)) { name = limitrx.left(); @@ -196,7 +207,15 @@ public class Sequence implements SequenceI */ public Sequence(SequenceI seq, AlignmentAnnotation[] alAnnotation) { - this(seq.getName(), seq.getSequence(), seq.getStart(), seq.getEnd()); + initSeqFrom(seq, alAnnotation); + + } + + protected void initSeqFrom(SequenceI seq, + AlignmentAnnotation[] alAnnotation) + { + initSeqAndName(seq.getName(), seq.getSequence(), seq.getStart(), + seq.getEnd()); description = seq.getDescription(); if (seq.getSequenceFeatures() != null) { @@ -353,21 +372,34 @@ public class Sequence implements SequenceI { if (pdbIds == null) { - pdbIds = new Vector(); + pdbIds = new Vector(); + } + if (pdbIds.contains(entry)) + { + updatePDBEntry(pdbIds.get(pdbIds.indexOf(entry)), entry); } - if (!pdbIds.contains(entry)) + else { pdbIds.addElement(entry); } } + private static void updatePDBEntry(PDBEntry oldEntry, PDBEntry newEntry) + { + if (newEntry.getFile() != null) + { + oldEntry.setFile(newEntry.getFile()); + } + } + /** * DOCUMENT ME! * * @param id * DOCUMENT ME! */ - public void setPDBId(Vector id) + @Override + public void setPDBId(Vector id) { pdbIds = id; } @@ -377,7 +409,8 @@ public class Sequence implements SequenceI * * @return DOCUMENT ME! */ - public Vector getPDBId() + @Override + public Vector getPDBId() { return pdbIds; } @@ -735,7 +768,7 @@ public class Sequence implements SequenceI public void deleteChars(int i, int j) { int newstart = start, newend = end; - if (i >= sequence.length) + if (i >= sequence.length || i < 0) { return; } @@ -935,7 +968,7 @@ public class Sequence implements SequenceI { if (this.annotation == null) { - this.annotation = new Vector(); + this.annotation = new Vector(); } if (!this.annotation.contains(annotation)) { @@ -1269,4 +1302,9 @@ public class Sequence implements SequenceI return result; } + public String toString() + { + return getDisplayId(false); + } + }