use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackIntervalFeature method findNextMatch.
public GenomicCoords findNextMatch(GenomicCoords currentGc, Pattern pattern) throws IOException, InvalidGenomicCoordsException {
IntervalFeature nextFeature = findNextRegexInGenome(pattern, currentGc.getChrom(), currentGc.getTo());
if (nextFeature == null) {
return currentGc;
}
GenomicCoords nextGc = new GenomicCoords(Utils.coordinatesToString(nextFeature.getChrom(), nextFeature.getFrom(), nextFeature.getFrom() + currentGc.getGenomicWindowSize() - 1), currentGc.getUserWindowSize(), currentGc.getSamSeqDict(), currentGc.getFastaFile());
return nextGc;
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TrackIntervalFeature method startEndOfNextFeature.
protected GenomicCoords startEndOfNextFeature(GenomicCoords currentGc, boolean getPrevious) throws InvalidGenomicCoordsException, IOException {
IntervalFeature nextFeature;
if (getPrevious) {
nextFeature = getPreviousFeature(currentGc.getChrom(), currentGc.getFrom());
} else {
nextFeature = getNextFeature(currentGc.getChrom(), currentGc.getTo());
}
if (nextFeature == null) {
return currentGc;
}
GenomicCoords nextGc = new GenomicCoords(Utils.coordinatesToString(nextFeature.getChrom(), nextFeature.getFrom(), nextFeature.getTo()), currentGc.getUserWindowSize(), currentGc.getSamSeqDict(), currentGc.getFastaFile());
return nextGc;
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TextReadTest method canPrintSquashedRead.
@Test
public void canPrintSquashedRead() throws InvalidGenomicCoordsException, IOException, InvalidColourException {
GenomicCoords gc = new GenomicCoords("chr7:5566778-5566978", 80, samSeqDict, fastaFile);
SAMRecord rec = new SAMRecord(null);
rec.setAlignmentStart(5566780);
rec.setCigarString("24M");
rec.setReadBases("AACCGGTTAACCGGTTAACCGGTT".getBytes());
TextRead textRead = new TextRead(rec, gc, false);
assertEquals(2, textRead.getTextStart());
assertEquals(11, textRead.getTextEnd());
assertEquals(textRead.getTextEnd() - textRead.getTextStart() + 1, ">>>>>>>>>>".length());
assertEquals(textRead.getPrintableTextRead(false, true, false), ">>>>>>>>>>");
// System.out.println(textRead);
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TextReadTest method canShowInsertion.
@Test
public void canShowInsertion() throws InvalidGenomicCoordsException, IOException, InvalidColourException {
GenomicCoords gc = new GenomicCoords("chr7:1-80", 80, null, null);
SAMRecord rec = new SAMRecord(null);
rec.setAlignmentStart(1);
rec.setCigarString("1M3I5M1I3M");
rec.setReadBases("AnnnACCGGnACT".getBytes());
TextRead tr = new TextRead(rec, gc, false);
// 7: code for "invert" colours. Checking for "[7;" is brittle since it assumes 7 is the first code.
assertEquals(2, StringUtils.countMatches(tr.getPrintableTextRead(false, false, false), "[7;"));
// Ensure it is the first base being marked. I.e. the "A".
assertTrue(tr.getPrintableTextRead(false, false, false).replaceAll("A.*", "").contains("[7;"));
// Hide insertion if resolution is not single base
GenomicCoords gc2 = new GenomicCoords("chr7:1-80", 79, null, null);
tr = new TextRead(rec, gc2, false);
assertTrue(!tr.getPrintableTextRead(false, false, false).contains("[7;"));
rec.setCigarString("4M");
rec.setReadBases("ACTG".getBytes());
tr = new TextRead(rec, gc, false);
assertTrue(!tr.getPrintableTextRead(false, false, false).contains("7"));
rec.setCigarString("1M");
rec.setReadBases("A".getBytes());
tr = new TextRead(rec, gc, false);
}
use of samTextViewer.GenomicCoords in project ASCIIGenome by dariober.
the class TextReadTest method canPrintDNARead.
// @Test
// public void canShowSoftClips() throws InvalidGenomicCoordsException, IOException, InvalidColourException {
//
// GenomicCoords gc= new GenomicCoords("chr7:1-80", 80, null, null);
// SAMRecord rec= new SAMRecord(null);
// rec.setAlignmentStart(1);
// rec.setCigarString("1S10M5S3H");
//
// TextRead textRead= new TextRead(rec, gc, true);
//
// System.err.println(textRead.getSoftUnclippedAlignmentStart(textRead.getSamRecord()));
//
// assertEquals(15, textRead.getTextEnd());
// assertEquals(1, textRead.getTextStart());
// // We start with N even if the first operation is S. This is because the
// // alignment starts at 1 so the first soft clip base(s) is lost on the left.
// assertTrue(textRead.getPrintableTextRead(false, true, false).startsWith("N"));
// assertTrue(textRead.getPrintableTextRead(false, true, false).endsWith("S"));
//
// rec.setCigarString("10S");
// textRead= new TextRead(rec, gc, true);
// assertEquals(10, textRead.getTextEnd());
// assertEquals(1, textRead.getTextStart());
//
// rec.setCigarString("1S10M");
// rec.setAlignmentStart(2);
// textRead= new TextRead(rec, gc, true);
// assertEquals(1, textRead.getTextStart());
//
// rec.setAlignmentStart(3);
// textRead= new TextRead(rec, gc, true);
// assertEquals(2, textRead.getTextStart());
//
// rec.setCigarString("1S2S10M");
// rec.setAlignmentStart(4);
// textRead= new TextRead(rec, gc, true);
// assertEquals(1, textRead.getTextStart());
// }
@Test
public void canPrintDNARead() throws InvalidGenomicCoordsException, IOException, InvalidColourException {
GenomicCoords gc = new GenomicCoords("chr7:5566778-5566798", 80, samSeqDict, fastaFile);
SAMRecord rec = new SAMRecord(null);
rec.setAlignmentStart(5566780);
rec.setCigarString("24M");
rec.setReadNegativeStrandFlag(true);
rec.setReadBases("AACCGGTTAACCGGTTAACCGGTT".getBytes());
TextRead textRead = new TextRead(rec, gc, false);
assertEquals(textRead.getTextStart(), 3);
assertEquals(textRead.getTextEnd(), 21);
assertEquals("AACCGGTTAACCGGTTAAC".length(), textRead.getTextEnd() - textRead.getTextStart() + 1);
System.out.println(textRead.getPrintableTextRead(false, true, false));
assertEquals("a,ccgg,t,acc,gtt,ac", textRead.getPrintableTextRead(false, true, false));
assertEquals("a,ccgg,t,uccmgtt,ac", textRead.getPrintableTextRead(true, true, false));
gc = new GenomicCoords("chr7:5566778-5566798", 80, samSeqDict, null);
textRead = new TextRead(rec, gc, false);
assertEquals("aaccggttaaccggttaac", textRead.getPrintableTextRead(false, true, false));
gc = new GenomicCoords("chr7:5566780-5566782", 80, samSeqDict, fastaFile);
textRead = new TextRead(rec, gc, false);
System.out.println(textRead.getPrintableTextRead(true, true, false));
System.out.println(textRead.getPrintableTextRead(true, false, false));
}
Aggregations