Make sure that the OverhangFixingManager (used for splitting RNA reads) handles unmapped reads.

This commit is contained in:
Eric Banks 2014-09-01 12:53:37 -04:00
parent 9477a6ab1a
commit ff91ab8ba2
3 changed files with 21 additions and 4 deletions

View File

@ -232,7 +232,7 @@ public class OverhangFixingManager {
*/
private void fixSplit(final SplitRead read, final Splice splice) {
// if the read doesn't even overlap the split position then we can just exit
if ( !splice.loc.overlapsP(read.loc) )
if ( read.loc == null || !splice.loc.overlapsP(read.loc) )
return;
if ( isLeftOverhang(read.loc, splice.loc) ) {
@ -326,7 +326,8 @@ public class OverhangFixingManager {
public void setRead(final GATKSAMRecord read) {
if ( !read.isEmpty() ) {
this.read = read;
loc = genomeLocParser.createGenomeLoc(read.getReferenceName(), read.getSoftStart(), read.getSoftEnd());
if ( ! read.getReadUnmappedFlag() )
loc = genomeLocParser.createGenomeLoc(read.getReferenceName(), read.getSoftStart(), read.getSoftEnd());
}
}
}

View File

@ -161,8 +161,6 @@ public class SplitNCigarReads extends ReadWalker<GATKSAMRecord, OverhangFixingMa
catch (FileNotFoundException ex) {
throw new UserException.CouldNotReadInputFile(toolkit.getArguments().referenceFile, ex);
}
}
@Override

View File

@ -50,6 +50,8 @@ import org.broadinstitute.gatk.utils.BaseTest;
import org.broadinstitute.gatk.utils.GenomeLoc;
import org.broadinstitute.gatk.utils.GenomeLocParser;
import org.broadinstitute.gatk.utils.fasta.CachingIndexedFastaSequenceFile;
import org.broadinstitute.gatk.utils.sam.ArtificialSAMUtils;
import org.broadinstitute.gatk.utils.sam.GATKSAMRecord;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
@ -169,4 +171,20 @@ public class OverhangFixingManagerUnitTest extends BaseTest {
final OverhangFixingManager manager = new OverhangFixingManager(null, genomeLocParser, referenceReader, 10000, 1, 40, false);
Assert.assertEquals(manager.overhangingBasesMismatch(read, readStart, ref, refStart, overhang), expected, new String(read) + " vs. " + new String(ref) + " @" + overhang);
}
@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);
}
}