X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSeqCigar.java;h=07abd538c186d2c8c33b4e1c56c75a6021dbc199;hb=451619e33c0a90c8130c7d79ffa38161af1c6e0f;hp=816e531db1c69d9879c9e71fa1a1fc763def04e7;hpb=c431a65bbe794a0dd27f3f806d3c5cf37c53279c;p=jalview.git diff --git a/src/jalview/datamodel/SeqCigar.java b/src/jalview/datamodel/SeqCigar.java index 816e531..07abd53 100644 --- a/src/jalview/datamodel/SeqCigar.java +++ b/src/jalview/datamodel/SeqCigar.java @@ -1,3 +1,21 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2006 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ package jalview.datamodel; import jalview.analysis.*; @@ -41,7 +59,7 @@ public class SeqCigar public String getSequenceString(char GapChar) { return (length == 0) ? "" : - (String) getSequenceAndDeletions(refseq.getSequence().substring(start, end), GapChar)[0]; + (String) getSequenceAndDeletions(refseq.getSequenceAsString(start, end), GapChar)[0]; } /** @@ -55,18 +73,20 @@ public class SeqCigar { return null; } - Object[] edit_result = getSequenceAndDeletions(refseq.getSequence().substring(start,end), + Object[] edit_result = getSequenceAndDeletions(refseq.getSequenceAsString(start,end), GapChar); if (edit_result == null) { throw new Error( "Implementation Error - unexpected null from getSequenceAndDeletions"); } - + int bounds[] = (int[]) edit_result[1]; seq = new Sequence(refseq.getName(), (String) edit_result[0], - refseq.getStart() + start+( (int[]) edit_result[1])[0], - refseq.getStart() + start+( (int[]) edit_result[1])[2]); + refseq.getStart() + start+bounds[0], + refseq.getStart() + start+((bounds[2]==0) ? -1 : bounds[2])); + // seq.checkValidRange(); probably not needed seq.setDatasetSequence(refseq); + seq.setDescription(refseq.getDescription()); return seq; } @@ -94,7 +114,7 @@ public class SeqCigar } if (_s<0) throw new Error("Implementation Error: _s="+_s); - String seq_string = seq.getSequence(); + String seq_string = seq.getSequenceAsString(); if (_e==0 || _e<_s || _e>seq_string.length()) _e=seq_string.length(); // resolve start and end positions relative to ungapped reference sequence @@ -356,7 +376,7 @@ public class SeqCigar for (int i = 0; i < alseqs.length; i++) { alseqs_string[i]=alseqs[i].getRefSeq(). - getSequence().substring(alseqs[i].start,alseqs[i].end); + getSequenceAsString(alseqs[i].start,alseqs[i].end); gs_regions[i] = alseqs[i].getSequenceAndDeletions(alseqs_string[i], gapCharacter); // gapped sequence, {start, start col, end. endcol}, hidden regions {{start, end, col}}) if (gs_regions[i] == null) { @@ -416,8 +436,9 @@ public class SeqCigar SequenceI ref = alseqs[i].getRefSeq(); seqs[i] = new Sequence(ref.getName(), g_seqs[i].toString(), ref.getStart() + alseqs[i].start+bounds[0], - ref.getStart() + alseqs[i].start+bounds[2]); + ref.getStart() + alseqs[i].start+(bounds[2]==0 ? -1 : bounds[2])); seqs[i].setDatasetSequence(ref); + seqs[i].setDescription(ref.getDescription()); } if (segments!=null) { for (int i=0; i