X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=098fdffa2e6b394916a5adfe7d040eac50e39159;hb=de337ac6b1859d64049325520bae15ae737345a8;hp=46871161c2eea5b89bb193ebe6e86b2fbb038548;hpb=4d2e0d36506302cc00677527725bcccbdf27d766;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 4687116..098fdff 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,6 +21,7 @@ package jalview.datamodel; import java.util.*; +import jalview.analysis.*; /** * DOCUMENT ME! @@ -28,7 +29,8 @@ import java.util.*; * @author $author$ * @version $Revision$ */ -public class Sequence implements SequenceI +public class Sequence + implements SequenceI { SequenceI datasetSequence; String name; @@ -47,10 +49,6 @@ public class Sequence implements SequenceI /** DOCUMENT ME!! */ 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. @@ -132,15 +130,48 @@ public class Sequence implements SequenceI } /** - * Creates a new Sequence object. - * + * Creates a new Sequence object with new features, DBRefEntries, AlignmentAnnotations, and PDBIds + * but inherits any existing dataset sequence reference. * @param seq DOCUMENT ME! */ public Sequence(SequenceI seq) { - this(seq.getName(), seq.getSequence(), seq.getStart(), seq.getEnd()); + this(seq.getName(), + seq.getSequence(), + seq.getStart(), + seq.getEnd()); + description = seq.getDescription(); + if (seq.getSequenceFeatures()!=null) { + SequenceFeature[] sf = seq.getSequenceFeatures(); + for (int i=0; i= sequence.length) { - System.out.println("DOES THIS GET CALLED???"); + return new char[0]; } if (end >= sequence.length) @@ -401,16 +440,27 @@ public class Sequence implements SequenceI public SequenceI getSubSequence(int start, int end) { if (start < 0) + { start = 0; + } char [] seq = getSequence(start, end); if (seq.length == 0) + { return null; + } int nstart = findPosition(start); int nend = findPosition(end) - 1; // JBPNote - this is an incomplete copy. SequenceI nseq = new Sequence(this.getName(), seq, nstart, nend); nseq.setDescription(description); - nseq.setDatasetSequence(getDatasetSequence()); + if (datasetSequence!=null) + { + nseq.setDatasetSequence(datasetSequence); + } + else + { + nseq.setDatasetSequence(this); + } return nseq; } @@ -454,11 +504,11 @@ public class Sequence implements SequenceI } /** - * DOCUMENT ME! + * Return the alignment position for a sequence position * - * @param pos DOCUMENT ME! + * @param pos lying from start to end * - * @return DOCUMENT ME! + * @return aligned position of residue pos */ public int findIndex(int pos) { @@ -564,9 +614,31 @@ public class Sequence implements SequenceI System.arraycopy(sequence,j,tmp,i,sequence.length-j); } + if (this.datasetSequence != null) + { + for (int s = i; s < j; s++) + { + if (jalview.schemes.ResidueProperties.aaIndex[sequence[s]] != 23) + { + + Sequence ds = new Sequence(name, + AlignSeq.extractGaps( + jalview.util.Comparison.GapChars, + this.getSequenceAsString() + ), + start, + end); + ds.setDescription(description); + } + break; + } + } + sequence = tmp; + } + /** * DOCUMENT ME! * @@ -632,17 +704,19 @@ public class Sequence implements SequenceI public void addDBRef(DBRefEntry entry) { if (dbrefs == null) + { dbrefs = new DBRefEntry[0]; + } int i, iSize = dbrefs.length; for(i=0; i