X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=80dfda54c35e56f521e290d007226b9b0d011e0a;hb=fbd79f8f62abc6337af57ab87ff07311eff1c74e;hp=d90c231aa9eeedb8c0e3f45c14b0233670a90beb;hpb=37382e89e23d86a2e728c61899904dd97dd07298;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index d90c231..80dfda5 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -33,7 +33,6 @@ public class Sequence implements SequenceI { SequenceI datasetSequence; String name; - String shortName; String sequence; String description; int start; @@ -45,7 +44,7 @@ public class Sequence implements SequenceI /** DOCUMENT ME!! */ - public Vector sequenceFeatures = new Vector(); + public Vector sequenceFeatures; /** * Creates a new Sequence object. @@ -58,70 +57,30 @@ public class Sequence implements SequenceI public Sequence(String name, String sequence, int start, int end) { this.name = name; - parseId(); - this.sequence = sequence; this.start = start; this.end = end; + parseId(); + checkValidRange(); } + static com.stevesoft.pat.Regex limitrx = new com.stevesoft.pat.Regex( + "[/][0-9]{1,}[-][0-9]{1,}$"); + static com.stevesoft.pat.Regex endrx = new com.stevesoft.pat.Regex( + "[0-9]{1,}$"); + void parseId() { - // Read in any DB refs first - StringTokenizer st = new StringTokenizer(name, "|"); - if(st.countTokens()<1) + // Does sequence have the /start-end signiature? + if(limitrx.search(name)) { - shortName = name; - return; + name = limitrx.left(); + endrx.search(limitrx.stringMatched()); + setStart( Integer.parseInt( limitrx.stringMatched().substring(1,endrx.matchedFrom()-1 ))); + setEnd( Integer.parseInt( endrx.stringMatched() )); } - - while (st.countTokens() > 1) - { - String a = st.nextToken(); - String b = st.nextToken(); - addDBRef(new DBRefEntry(a, "0", b)); - } - - if (st.hasMoreTokens()) - shortName = st.nextToken(); - - // Remove /start-end from sequence - if (shortName.indexOf("/") > 0) - { - st = new StringTokenizer(shortName, "/"); - String limits = null; - try - { - if (st.countTokens() == 2) - { - - shortName = st.nextToken(); - - limits = st.nextToken(); - - st = new StringTokenizer(limits, "-"); - - if (st.countTokens() == 2) - { - setStart(Integer.valueOf(st.nextToken()).intValue()); - setEnd(Integer.valueOf(st.nextToken()).intValue()); - } - } - - // If we're still in this loop, parsing of start and end was ok - // Therefore remove it from the sequence name - name = name.substring(0, name.indexOf("/")); - } - catch (NumberFormatException ex) - { - // Problem parsing sequence limits. Just add it back to the - // Id so we dont lose this info - shortName += "/" + limits; - } - } - } void checkValidRange() @@ -197,6 +156,14 @@ public class Sequence implements SequenceI return sequenceFeatures; } + public void addPDBId(PDBEntry entry) + { + if(pdbIds == null) + pdbIds = new Vector(); + + pdbIds.addElement(entry); + } + /** * DOCUMENT ME! * @@ -222,20 +189,9 @@ public class Sequence implements SequenceI * * @return DOCUMENT ME! */ - public String getDisplayId(boolean dbref, boolean jvsuffix) + public String getDisplayId(boolean jvsuffix) { - StringBuffer result = new StringBuffer(); - if (dbref && dbrefs != null) - { - for (int i = 0; i < dbrefs.size(); i++) - { - DBRefEntry entry = (DBRefEntry) dbrefs.elementAt(i); - result.append(entry.getSource() + "|" + entry.getAccessionId() + "|"); - } - } - - result.append(shortName); - + StringBuffer result = new StringBuffer(name); if (jvsuffix) { result.append("/" + start + "-" + end); @@ -414,9 +370,7 @@ public class Sequence implements SequenceI while ((i < sequence.length()) && (j <= end) && (j <= pos)) { - char c = sequence.charAt(i); - - if (!jalview.util.Comparison.isGap((c))) + if (!jalview.util.Comparison.isGap(sequence.charAt(i))) { j++; } @@ -449,9 +403,7 @@ public class Sequence implements SequenceI while ((j < i) && (j < sequence.length())) { - char c = sequence.charAt(j); - - if (!jalview.util.Comparison.isGap((c))) + if (!jalview.util.Comparison.isGap((sequence.charAt(j)))) { pos++; }