@BeforeClass public void init() { SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000); read = ArtificialSAMUtils.createArtificialRead(header, "read1", 0, 1, BASES.length()); read.setReadUnmappedFlag(true); read.setReadBases(new String(BASES).getBytes()); read.setBaseQualityString(new String(QUALS)); }
@Test( ) public void testCreationFromSAMRecordUnmapped() { final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "foo", 0, 1, 5); read.setReadUnmappedFlag(true); read.setReferenceIndex(-1); final GenomeLoc loc = genomeLocParser.createGenomeLoc(read); Assert.assertTrue(loc.isUnmapped()); }
/** * Create an artificial read based on the parameters. The cigar string will be *M, where * is the length of the read * * @param header the SAM header to associate the read with * @param name the name of the read * @param refIndex the reference index, i.e. what chromosome to associate it with * @param alignmentStart where to start the alignment * @param bases the sequence of the read * @param qual the qualities of the read * @return the artificial read */ public static GATKSAMRecord createArtificialRead(SAMFileHeader header, String name, int refIndex, int alignmentStart, byte[] bases, byte[] qual) { if (bases.length != qual.length) { throw new ReviewedGATKException("Passed in read string is different length then the quality array"); } GATKSAMRecord rec = createArtificialRead(header, name, refIndex, alignmentStart, bases.length); rec.setReadBases(bases); rec.setBaseQualities(qual); rec.setReadGroup(new GATKSAMReadGroupRecord("x")); if (refIndex == -1) { rec.setReadUnmappedFlag(true); } return rec; }
@Test( ) public void testCreationFromSAMRecordUnmappedButOnGenome() { final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "foo", 0, 1, 5); read.setReadUnmappedFlag(true); read.setCigarString("*"); final GenomeLoc loc = genomeLocParser.createGenomeLoc(read); Assert.assertEquals(loc.getContig(), read.getReferenceName()); Assert.assertEquals(loc.getContigIndex(), (int)read.getReferenceIndex()); Assert.assertEquals(loc.getStart(), read.getAlignmentStart()); Assert.assertEquals(loc.getStop(), read.getAlignmentStart()); }
record.setReadUnmappedFlag(true);
@Test public void testUnmappedReadsDoNotFail() { // create an unmapped read final GATKSAMRecord read = new GATKSAMRecord(ArtificialSAMUtils.createArtificialSamHeader()); read.setReadName("foo"); read.setReferenceName("*"); read.setAlignmentStart(100); read.setCigarString("*"); read.setReadUnmappedFlag(true); // try to add it to the manager final OverhangFixingManager manager = new OverhangFixingManager(null, null, null, 100, 1, 30, false); manager.addRead(read); // we just want to make sure that the following call does not fail Assert.assertTrue(true); } }
@Test(enabled = !DEBUG) public void testUnmappedAndAllIReadsPassThrough() { final int readLength = 10; GATKSAMRecord mapped1 = ArtificialSAMUtils.createArtificialRead(header,"mapped1",0,1,readLength); GATKSAMRecord mapped2 = ArtificialSAMUtils.createArtificialRead(header,"mapped2",0,1,readLength); GATKSAMRecord unmapped = ArtificialSAMUtils.createArtificialRead(header,"unmapped",0,1,readLength); GATKSAMRecord allI = ArtificialSAMUtils.createArtificialRead(header,"allI",0,1,readLength); unmapped.setReadUnmappedFlag(true); unmapped.setCigarString("*"); allI.setCigarString(readLength + "I"); List<GATKSAMRecord> reads = Arrays.asList(mapped1, unmapped, allI, mapped2); // create the iterator by state with the fake reads and fake records li = makeLTBS(reads, DownsamplingMethod.NONE, true); Assert.assertTrue(li.hasNext()); AlignmentContext context = li.next(); ReadBackedPileup pileup = context.getBasePileup(); Assert.assertEquals(pileup.depthOfCoverage(), 2, "Should see only 2 reads in pileup, even with unmapped and all I reads"); final List<GATKSAMRecord> rawReads = li.transferReadsFromAllPreviousPileups(); Assert.assertEquals(rawReads, reads, "Input and transferred read lists should be the same, and include the unmapped and all I reads"); }
read.setProperPairFlag(true); read.setReadPairedFlag(true); read.setReadUnmappedFlag(false); read.setMateUnmappedFlag(false); read.setReadBases(Utils.dupBytes((byte) 'A', readLength));
read.setReadPairedFlag(true); read.setProperPairFlag(true); read.setReadUnmappedFlag(false); read.setMateUnmappedFlag(false); read.setAlignmentStart(100); bad.setReadUnmappedFlag(true); tests.add( new Object[]{ "read is unmapped", bad, false });
/** * Write out a representation of this haplotype as a read * * @param haplotype a haplotype to write out. Cannot be null * @param paddedRefLoc the reference location. Cannot be null * @param isAmongBestHaplotypes true if among the best haplotypes, false if it was just one possible but not so good */ private void writeHaplotype(final Haplotype haplotype, final GenomeLoc paddedRefLoc, final boolean isAmongBestHaplotypes) { final GATKSAMRecord record = new GATKSAMRecord(output.getHeader()); record.setReadBases(haplotype.getBases()); record.setAlignmentStart(paddedRefLoc.getStart() + haplotype.getAlignmentStartHapwrtRef()); record.setBaseQualities(Utils.dupBytes((byte) '!', haplotype.getBases().length)); record.setCigar(AlignmentUtils.consolidateCigar(haplotype.getCigar())); record.setMappingQuality(isAmongBestHaplotypes ? 60 : 0); record.setReadName("HC" + uniqueNameCounter++); record.setAttribute(AlignmentUtils.HAPLOTYPE_TAG,haplotype.hashCode()); record.setReadUnmappedFlag(false); record.setReferenceIndex(paddedRefLoc.getContigIndex()); record.setAttribute(SAMTag.RG.toString(), READ_GROUP_ID); record.setFlags(16); output.add(record); }
read.setReadUnmappedFlag(true); boundary = get.getAdaptor(read); Assert.assertEquals(boundary, ReadUtils.CANNOT_COMPUTE_ADAPTOR_BOUNDARY); read.setReadUnmappedFlag(false);