+/*
+ * 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.*;
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];
}
/**
{
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;
}
}
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
{
this.addOperation(M, range);
}
-
- /**
- * Deleted regions mean that there will be discontinuous sequence numbering in the
- * sequence returned by getSeq(char).
- * @return true if there deletions
- */
- public boolean hasDeletedRegions()
- {
- for (int i = 0, l = length; i < l; i++)
- {
- if (operation[i] == D)
- {
- return true;
- }
- }
- return false;
- }
-
/**
* Adds
* insertion and match operations based on seq to the cigar up to
* @return SequenceI[]
*/
public static SequenceI[] createAlignmentSequences(SeqCigar[] alseqs,
- char gapCharacter, ColumnSelection colsel)
+ char gapCharacter, ColumnSelection colsel, int[] segments)
{
SequenceI[] seqs = new SequenceI[alseqs.length];
- Vector hiddenRegions=new Vector();
StringBuffer[] g_seqs = new StringBuffer[alseqs.length];
String[] alseqs_string=new String[alseqs.length];
Object[] gs_regions = new Object[alseqs.length];
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)
{
}
g_seqs[i] = new StringBuffer( (String) ( (Object[]) gs_regions[i])[0]); // the visible gapped sequence
}
- // Now account for insertions.
+ // Now account for insertions. (well - deletions)
// this is complicated because we must keep track of shifted positions in each sequence
ShiftList shifts = new ShiftList();
for (int i = 0; i < alseqs.length; i++)
}
}
shifts.addShift(region[2], insert.length); // update shift in alignment frame of reference
- colsel.hideColumns(inspos, inspos+insert.length-1);
+ if (segments==null)
+ // add a hidden column for this deletion
+ colsel.hideColumns(inspos, inspos+insert.length-1);
}
}
}
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<segments.length; i+=3) {
+ //int start=shifts.shift(segments[i]-1)+1;
+ //int end=shifts.shift(segments[i]+segments[i+1]-1)-1;
+ colsel.hideColumns(segments[i+1], segments[i+1]+segments[i+2]-1);
+ }
}
return seqs;
}
{
sub_se_gp = new SeqCigar(s_subsequence_gapped, 8, 48);
int sl = sub_se_gp.getWidth();
- int st = sl - r - r;
+ int st = sl - 1 - r;
for (int rs = 0; rs < 10; rs++)
{
int e = st + rs;
sub_se_gp.deleteRange(st, e);
- String ssgapedseq = sub_se_gp.getSeq('-').getSequence();
+ String ssgapedseq = sub_se_gp.getSeq('-').getSequenceAsString();
System.out.println(st + "," + e + "\t:" + ssgapedseq);
+ st -=3;
}
}
{