X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=9e9344434018382d59b303001fab3133d42f296c;hb=a6c05e6488b5acb43d0ad3aeced88c2dcbe83a4c;hp=f4795f1cb993f1d1f64a5856716822e27bdca324;hpb=b13f521553582ef2fbfd7815ae25e23284babdea;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index f4795f1..9e93444 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,8 +20,6 @@ */ package jalview.datamodel; -import jalview.analysis.AlignSeq; - import java.util.ArrayList; import java.util.Enumeration; import java.util.List; @@ -29,6 +27,9 @@ import java.util.Vector; import fr.orsay.lri.varna.models.rna.RNA; +import jalview.analysis.AlignSeq; +import jalview.util.StringUtils; + /** * * Implements the SequenceI interface for a char[] based sequence object. @@ -50,7 +51,7 @@ public class Sequence implements SequenceI int end; - Vector pdbIds; + Vector pdbIds; String vamsasId; @@ -58,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 @@ -120,7 +122,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(); @@ -352,21 +354,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; } @@ -376,7 +391,8 @@ public class Sequence implements SequenceI * * @return DOCUMENT ME! */ - public Vector getPDBId() + @Override + public Vector getPDBId() { return pdbIds; } @@ -739,24 +755,12 @@ public class Sequence implements SequenceI return; } - char[] tmp; - - if (j >= sequence.length) - { - tmp = new char[i]; - System.arraycopy(sequence, 0, tmp, 0, i); - j = sequence.length; - } - else - { - tmp = new char[sequence.length - j + i]; - System.arraycopy(sequence, 0, tmp, 0, i); - System.arraycopy(sequence, j, tmp, i, sequence.length - j); - } + char[] tmp = StringUtils.deleteChars(sequence, i, j); boolean createNewDs = false; - // TODO: take a look at the new dataset creation validation method below - - // this could become time comsuming for large sequences - consider making it - // more efficient + // TODO: take a (second look) at the dataset creation validation method for + // the very large sequence case + int eindex = -1, sindex = -1; + boolean ecalc = false, scalc = false; for (int s = i; s < j; s++) { if (jalview.schemes.ResidueProperties.aaIndex[sequence[s]] != 23) @@ -767,7 +771,11 @@ public class Sequence implements SequenceI } else { - int sindex = findIndex(start) - 1; + if (!scalc) + { + sindex = findIndex(start) - 1; + scalc = true; + } if (sindex == s) { // delete characters including start of sequence @@ -777,7 +785,11 @@ public class Sequence implements SequenceI else { // delete characters after start. - int eindex = findIndex(end) - 1; + if (!ecalc) + { + eindex = findIndex(end) - 1; + ecalc = true; + } if (eindex < j) { // delete characters at end of sequence @@ -938,7 +950,7 @@ public class Sequence implements SequenceI { if (this.annotation == null) { - this.annotation = new Vector(); + this.annotation = new Vector(); } if (!this.annotation.contains(annotation)) { @@ -1037,7 +1049,7 @@ public class Sequence implements SequenceI AlignmentAnnotation _aa = new AlignmentAnnotation(aa); _aa.sequenceRef = datasetSequence; _aa.adjustForAlignment(); // uses annotation's own record of - // sequence-column mapping + // sequence-column mapping datasetSequence.addAlignmentAnnotation(_aa); } } @@ -1258,8 +1270,10 @@ public class Sequence implements SequenceI String label) { List result = new ArrayList(); - if (this.annotation != null) { - for (AlignmentAnnotation ann : annotation) { + if (this.annotation != null) + { + for (AlignmentAnnotation ann : annotation) + { if (ann.calcId != null && ann.calcId.equals(calcId) && ann.label != null && ann.label.equals(label)) { @@ -1270,4 +1284,5 @@ public class Sequence implements SequenceI return result; } + }