while (ds.getDatasetSequence()!=null) {
ds=ds.getDatasetSequence();
}
+ int s_end = s.findPosition(s.getStart()+s.getLength());
// find available flanking residues for sequence
- int ustream_ds=s.getStart()-ds.getStart(),dstream_ds=ds.getEnd()-s.getEnd();
+ int ustream_ds=s.getStart()-ds.getStart(),dstream_ds=ds.getEnd()-s_end;
// build new flanked sequence
}
}
char[] upstream = new String(ds.getSequence(s.getStart()-1-ustream_ds, s.getStart()-1)).toLowerCase().toCharArray();
- char[] downstream = new String(ds.getSequence(s.getEnd()+1,s.getEnd()+1+dstream_ds)).toLowerCase().toCharArray();
+ char[] downstream = new String(ds.getSequence(s_end-1,s_end+1+dstream_ds)).toLowerCase().toCharArray();
char[] coreseq=s.getSequence();
char[] nseq = new char[offset+upstream.length+downstream.length+coreseq.length];
char c = core.getGapCharacter();
System.arraycopy(downstream, 0, nseq, p+coreseq.length+upstream.length, downstream.length);
s.setSequence(new String(nseq));
s.setStart(s.getStart()-ustream_ds);
- s.setEnd(s.getEnd()+downstream.length);
+ s.setEnd(s_end+downstream.length);
}
AlignmentI newAl = new jalview.datamodel.Alignment(sq.toArray(new SequenceI[0]));
newAl.setDataset(core.getDataset());
package jalview.analysis;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import jalview.datamodel.Alignment;
System.out.println(new AppletFormatAdapter().formatSequences("Clustal", al, true));
for (int flnk=-1;flnk<25; flnk++)
{
+ AlignmentI exp;
System.out.println("\nFlank size: "+flnk);
- System.out.println(new AppletFormatAdapter().formatSequences("Clustal", AlignmentUtils.expandContext(al, flnk), true));
+ System.out.println(new AppletFormatAdapter().formatSequences("Clustal", exp=AlignmentUtils.expandContext(al, flnk), true));
+ if (flnk==-1) {
+ for (SequenceI sq:exp.getSequences())
+ {
+ String ung = sq.getSequenceAsString().replaceAll("-+", "");
+ assertTrue("Flanking sequence not the same as original dataset sequence.\n"+ung+"\n"+sq.getDatasetSequence().getSequenceAsString(),ung.equalsIgnoreCase(sq.getDatasetSequence().getSequenceAsString()));
+ }
+ }
}
}
}