X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=09c9a696a7de8f5c60c8db5513666360bf1bbec0;hb=daa33859b015a7e4b1295addfff2582bf348b8bc;hp=d30003dd45822cf9d25fb79ffe09a4ddcbe272f6;hpb=f24dacb1da56fccf05d684e2f4899facec2aecf7;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index d30003d..09c9a69 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -31,17 +31,28 @@ import java.util.*; */ public class Sequence implements SequenceI { - protected String name; - protected String sequence; - protected String description; - protected int start; - protected int end; - protected String displayId; - protected Color color = Color.white; - String pdbId; + SequenceI datasetSequence; + String name; + String sequence; + String description; + int start; + int end; + Color color = Color.white; + Vector pdbIds; + String vamsasId; + Vector dbrefs; + + /** This annotation is displayed below the alignment but the + * positions are tied to the residues of this sequence */ + Vector annotation; /** DOCUMENT ME!! */ - public Vector sequenceFeatures = new Vector(); + public SequenceFeature [] sequenceFeatures; + + /** This array holds hidden sequences + * of which this sequence is the representitive member of a group + */ + SequenceGroup hiddenSequences; /** * Creates a new Sequence object. @@ -58,6 +69,30 @@ public class Sequence implements SequenceI this.start = start; this.end = end; + parseId(); + + checkValidRange(); + } + + com.stevesoft.pat.Regex limitrx = new com.stevesoft.pat.Regex( + "[/][0-9]{1,}[-][0-9]{1,}$"); + com.stevesoft.pat.Regex endrx = new com.stevesoft.pat.Regex( + "[0-9]{1,}$"); + + void parseId() + { + // Does sequence have the /start-end signiature? + if(limitrx.search(name)) + { + name = limitrx.left(); + endrx.search(limitrx.stringMatched()); + setStart( Integer.parseInt( limitrx.stringMatched().substring(1,endrx.matchedFrom()-1 ))); + setEnd( Integer.parseInt( endrx.stringMatched() )); + } + } + + void checkValidRange() + { if (end < 1) { int endRes = 0; @@ -78,7 +113,6 @@ public class Sequence implements SequenceI this.end = endRes; } - setDisplayId(); } /** @@ -89,7 +123,7 @@ public class Sequence implements SequenceI */ public Sequence(String name, String sequence) { - this(name, sequence, 1, sequence.length()); + this(name, sequence, 1, -1); } /** @@ -107,29 +141,61 @@ public class Sequence implements SequenceI * * @param v DOCUMENT ME! */ - public void setSequenceFeatures(Vector v) + public void setSequenceFeatures(SequenceFeature [] features) { - sequenceFeatures = v; + sequenceFeatures = features; } + public void addSequenceFeature(SequenceFeature sf) + { + if(sequenceFeatures==null) + { + sequenceFeatures = new SequenceFeature[0]; + } + + for(int i=0; isequence.length()) + end = sequence.length(); + + if (start > 0) + { + newSeq.append(sequence.substring(0, start)); + } + + if (toUpper) + newSeq.append(sequence.substring(start, end).toUpperCase()); + else + newSeq.append(sequence.substring(start, end).toLowerCase()); + + if (end < sequence.length()) + newSeq.append(sequence.substring(end)); + + sequence = newSeq.toString(); + } + + public void toggleCase(int start, int end) + { + StringBuffer newSeq = new StringBuffer(); + + if(end>sequence.length()) + end = sequence.length(); + + if (start > 0) + { + newSeq.append(sequence.substring(0, start)); + } + + char nextChar; + for(int c=start; c