X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=290cdfc10dfa46ab7ba09734be35bf2e55038b8c;hb=10ddc20a773099eaf0dc4d9d1bbb3b88b4176ed4;hp=34c1cd917f6f0fb252de743de48435710db7bfae;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 34c1cd9..290cdfc 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -18,10 +18,6 @@ */ package jalview.datamodel; -import MCview.*; - -import jalview.analysis.*; - import java.awt.*; import java.util.*; @@ -35,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. @@ -57,12 +64,55 @@ public class Sequence implements SequenceI */ public Sequence(String name, String sequence, int start, int end) { - this.name = name; - this.sequence = sequence; - this.start = start; - this.end = end; + this.name = name; + this.sequence = sequence; + 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; + char ch; + for (int j = 0; j < sequence.length(); j++) + { + ch = sequence.charAt(j); + if (!jalview.util.Comparison.isGap( (ch))) + { + endRes++; + } + } + if (endRes > 0) + { + endRes += start - 1; + } + + this.end = endRes; + } - setDisplayId(); } /** @@ -73,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); } /** @@ -91,29 +141,68 @@ public class Sequence implements SequenceI * * @param v DOCUMENT ME! */ - public void setSequenceFeatures(Vector v) + public void setSequenceFeatures(SequenceFeature [] features) + { + sequenceFeatures = features; + } + + public void addSequenceFeature(SequenceFeature sf) { - sequenceFeatures = v; + 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