From ace4dda1b45a307e7f115c95d53175f9caeb39fa Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 30 Nov 2015 09:19:11 +0000 Subject: [PATCH] JAL-1421 use generics JAL-1551 @Override annotations added --- src/jalview/datamodel/Sequence.java | 39 +++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index c7581d8..532a11b 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -261,11 +261,10 @@ public class Sequence extends ASequence implements SequenceI } if (seq.getAllPDBEntries() != null) { - Vector ids = seq.getAllPDBEntries(); - Enumeration e = ids.elements(); - while (e.hasMoreElements()) + Vector ids = seq.getAllPDBEntries(); + for (PDBEntry pdb : ids) { - this.addPDBId(new PDBEntry((PDBEntry) e.nextElement())); + this.addPDBId(new PDBEntry(pdb)); } } } @@ -276,11 +275,13 @@ public class Sequence extends ASequence implements SequenceI * @param v * DOCUMENT ME! */ + @Override public void setSequenceFeatures(SequenceFeature[] features) { sequenceFeatures = features; } + @Override public synchronized void addSequenceFeature(SequenceFeature sf) { if (sequenceFeatures == null) @@ -303,6 +304,7 @@ public class Sequence extends ASequence implements SequenceI sequenceFeatures = temp; } + @Override public void deleteFeature(SequenceFeature sf) { if (sequenceFeatures == null) @@ -352,6 +354,7 @@ public class Sequence extends ASequence implements SequenceI * * @return */ + @Override public SequenceFeature[] getSequenceFeatures() { SequenceFeature[] features = sequenceFeatures; @@ -367,6 +370,7 @@ public class Sequence extends ASequence implements SequenceI return features; } + @Override public void addPDBId(PDBEntry entry) { if (pdbIds == null) @@ -419,6 +423,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public String getDisplayId(boolean jvsuffix) { StringBuffer result = new StringBuffer(name); @@ -436,6 +441,7 @@ public class Sequence extends ASequence implements SequenceI * @param name * DOCUMENT ME! */ + @Override public void setName(String name) { this.name = name; @@ -447,6 +453,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public String getName() { return this.name; @@ -458,6 +465,7 @@ public class Sequence extends ASequence implements SequenceI * @param start * DOCUMENT ME! */ + @Override public void setStart(int start) { this.start = start; @@ -468,6 +476,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public int getStart() { return this.start; @@ -479,6 +488,7 @@ public class Sequence extends ASequence implements SequenceI * @param end * DOCUMENT ME! */ + @Override public void setEnd(int end) { this.end = end; @@ -489,6 +499,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public int getEnd() { return this.end; @@ -499,6 +510,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public int getLength() { return this.sequence.length; @@ -510,22 +522,26 @@ public class Sequence extends ASequence implements SequenceI * @param seq * DOCUMENT ME! */ + @Override public void setSequence(String seq) { this.sequence = seq.toCharArray(); checkValidRange(); } + @Override public String getSequenceAsString() { return new String(sequence); } + @Override public String getSequenceAsString(int start, int end) { return new String(getSequence(start, end)); } + @Override public char[] getSequence() { return sequence; @@ -536,6 +552,7 @@ public class Sequence extends ASequence implements SequenceI * * @see jalview.datamodel.SequenceI#getSequence(int, int) */ + @Override public char[] getSequence(int start, int end) { if (start < 0) @@ -596,6 +613,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public char getCharAt(int i) { if (i < sequence.length) @@ -614,6 +632,7 @@ public class Sequence extends ASequence implements SequenceI * @param desc * DOCUMENT ME! */ + @Override public void setDescription(String desc) { this.description = desc; @@ -624,6 +643,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public String getDescription() { return this.description; @@ -634,6 +654,7 @@ public class Sequence extends ASequence implements SequenceI * * @see jalview.datamodel.SequenceI#findIndex(int) */ + @Override public int findIndex(int pos) { // returns the alignment position for a residue @@ -686,6 +707,7 @@ public class Sequence extends ASequence implements SequenceI * @return int[SequenceI.getEnd()-SequenceI.getStart()+1] or null if no * residues in SequenceI object */ + @Override public int[] gapMap() { String seq = jalview.analysis.AlignSeq.extractGaps( @@ -937,6 +959,7 @@ public class Sequence extends ASequence implements SequenceI @Override public void setDatasetSequence(SequenceI seq) { + // TODO check for circular reference before setting? datasetSequence = seq; } @@ -973,6 +996,7 @@ public class Sequence extends ASequence implements SequenceI annotation.setSequenceRef(this); } + @Override public void removeAlignmentAnnotation(AlignmentAnnotation annotation) { if (this.annotation != null) @@ -1040,6 +1064,7 @@ public class Sequence extends ASequence implements SequenceI * * @see jalview.datamodel.SequenceI#createDatasetSequence() */ + @Override public SequenceI createDatasetSequence() { if (datasetSequence == null) @@ -1078,6 +1103,7 @@ public class Sequence extends ASequence implements SequenceI * jalview.datamodel.SequenceI#setAlignmentAnnotation(AlignmmentAnnotation[] * annotations) */ + @Override public void setAlignmentAnnotation(AlignmentAnnotation[] annotations) { if (annotation != null) @@ -1250,6 +1276,7 @@ public class Sequence extends ASequence implements SequenceI * @return The index (zero-based) on this sequence in the MSA. It returns * {@code -1} if this information is not available. */ + @Override public int getIndex() { return index; @@ -1263,16 +1290,19 @@ public class Sequence extends ASequence implements SequenceI * position for this sequence. This value is zero-based (zero for * this first sequence) */ + @Override public void setIndex(int value) { index = value; } + @Override public void setRNA(RNA r) { rna = r; } + @Override public RNA getRNA() { return rna; @@ -1297,6 +1327,7 @@ public class Sequence extends ASequence implements SequenceI return result; } + @Override public String toString() { return getDisplayId(false); -- 1.7.10.2