Search in sources :

Example 1 with Read

use of com.google.api.services.genomics.model.Read in project gatk by broadinstitute.

the class ArtificialReadUtils method createArtificialGoogleGenomicsRead.

public static Read createArtificialGoogleGenomicsRead(final String name, final String contig, final int start, final byte[] bases, final byte[] quals, final String cigar) {
    Read googleRead = new Read();
    googleRead.setFragmentName(name);
    googleRead.setAlignment(new LinearAlignment());
    googleRead.getAlignment().setPosition(new Position());
    googleRead.getAlignment().getPosition().setReferenceName(contig);
    googleRead.getAlignment().getPosition().setPosition((long) start - 1);
    googleRead.setAlignedSequence(StringUtil.bytesToString(bases));
    googleRead.getAlignment().setCigar(CigarConversionUtils.convertSAMCigarToCigarUnitList(TextCigarCodec.decode(cigar)));
    List<Integer> convertedQuals = new ArrayList<>();
    for (byte b : quals) {
        convertedQuals.add((int) b);
    }
    googleRead.setAlignedQuality(convertedQuals);
    // Create a fully formed read that can be wrapped by a GATKRead and have a valid
    // SAMString without GATKRead throwing missing field exceptions.
    googleRead.setFailedVendorQualityChecks(false);
    googleRead.setSecondaryAlignment(false);
    googleRead.setSupplementaryAlignment(false);
    googleRead.setDuplicateFragment(false);
    Position matePos = new Position();
    matePos.setReverseStrand(false);
    googleRead.setNextMatePosition(matePos);
    return googleRead;
}
Also used : Read(com.google.api.services.genomics.model.Read) LinearAlignment(com.google.api.services.genomics.model.LinearAlignment) Position(com.google.api.services.genomics.model.Position)

Example 2 with Read

use of com.google.api.services.genomics.model.Read in project gatk by broadinstitute.

the class ReadUtilsUnitTest method readHasNoAssignedPositionTestData.

@DataProvider(name = "ReadHasNoAssignedPositionTestData")
public Object[][] readHasNoAssignedPositionTestData() {
    final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader();
    // To test the "null contig" cases, we need to use a Google Genomics Read, since SAMRecord doesn't allow it
    final Read unmappedGoogleReadWithNullContigSetStart = new Read();
    unmappedGoogleReadWithNullContigSetStart.setAlignment(new LinearAlignment());
    unmappedGoogleReadWithNullContigSetStart.getAlignment().setPosition(new Position());
    unmappedGoogleReadWithNullContigSetStart.getAlignment().getPosition().setReferenceName(null);
    unmappedGoogleReadWithNullContigSetStart.getAlignment().getPosition().setPosition(10l);
    final GATKRead unmappedReadWithNullContigSetStart = new GoogleGenomicsReadToGATKReadAdapter(unmappedGoogleReadWithNullContigSetStart);
    final Read unmappedGoogleReadWithNullContigUnsetStart = new Read();
    unmappedGoogleReadWithNullContigUnsetStart.setAlignment(new LinearAlignment());
    unmappedGoogleReadWithNullContigUnsetStart.getAlignment().setPosition(new Position());
    unmappedGoogleReadWithNullContigUnsetStart.getAlignment().getPosition().setReferenceName(null);
    unmappedGoogleReadWithNullContigUnsetStart.getAlignment().getPosition().setPosition(Long.valueOf(ReadConstants.UNSET_POSITION));
    final GATKRead unmappedReadWithNullContigUnsetStart = new GoogleGenomicsReadToGATKReadAdapter(unmappedGoogleReadWithNullContigUnsetStart);
    // We'll also test the improbable case of a SAMRecord marked as mapped, but with an unset contig/start
    final SAMRecord mappedSAMWithUnsetContigSetStart = new SAMRecord(header);
    mappedSAMWithUnsetContigSetStart.setReferenceName(ReadConstants.UNSET_CONTIG);
    mappedSAMWithUnsetContigSetStart.setAlignmentStart(10);
    mappedSAMWithUnsetContigSetStart.setReadUnmappedFlag(false);
    final GATKRead mappedReadWithUnsetContigSetStart = new SAMRecordToGATKReadAdapter(mappedSAMWithUnsetContigSetStart);
    final SAMRecord mappedSAMWithSetContigUnsetStart = new SAMRecord(header);
    mappedSAMWithSetContigUnsetStart.setReferenceName("1");
    mappedSAMWithSetContigUnsetStart.setAlignmentStart(ReadConstants.UNSET_POSITION);
    mappedSAMWithSetContigUnsetStart.setReadUnmappedFlag(false);
    final GATKRead mappedReadWithSetContigUnsetStart = new SAMRecordToGATKReadAdapter(mappedSAMWithSetContigUnsetStart);
    return new Object[][] { // Mapped read with position
    { ArtificialReadUtils.createArtificialRead(header, "foo", 0, 5, 10), false }, // Basic unmapped read with no position
    { ArtificialReadUtils.createArtificialUnmappedRead(header, new byte[] { 'A' }, new byte[] { 30 }), true }, // Unmapped read with set position (contig and start)
    { ArtificialReadUtils.createArtificialUnmappedReadWithAssignedPosition(header, "1", 10, new byte[] { 'A' }, new byte[] { 30 }), false }, // Unmapped read with null contig, set start
    { unmappedReadWithNullContigSetStart, true }, // Unmapped read with "*" contig, set start
    { ArtificialReadUtils.createArtificialUnmappedReadWithAssignedPosition(header, ReadConstants.UNSET_CONTIG, 10, new byte[] { 'A' }, new byte[] { 30 }), true }, // Unmapped read with set contig, unset start
    { ArtificialReadUtils.createArtificialUnmappedReadWithAssignedPosition(header, "1", ReadConstants.UNSET_POSITION, new byte[] { 'A' }, new byte[] { 30 }), true }, // Unmapped read with null contig, unset start
    { unmappedReadWithNullContigUnsetStart, true }, // Unmapped read with "*" contig, unset start
    { ArtificialReadUtils.createArtificialUnmappedReadWithAssignedPosition(header, ReadConstants.UNSET_CONTIG, ReadConstants.UNSET_POSITION, new byte[] { 'A' }, new byte[] { 30 }), true }, // "Mapped" read with unset contig, set start
    { mappedReadWithUnsetContigSetStart, true }, // "Mapped" read with set contig, unset start
    { mappedReadWithSetContigUnsetStart, true } };
}
Also used : Read(com.google.api.services.genomics.model.Read) LinearAlignment(com.google.api.services.genomics.model.LinearAlignment) Position(com.google.api.services.genomics.model.Position) SAMRecord(htsjdk.samtools.SAMRecord) SAMFileHeader(htsjdk.samtools.SAMFileHeader) DataProvider(org.testng.annotations.DataProvider)

Example 3 with Read

use of com.google.api.services.genomics.model.Read in project gatk by broadinstitute.

the class GATKReadAdaptersUnitTest method getAndSetBaseQualitiesData.

@DataProvider(name = "GetAndSetBaseQualitiesData")
public Object[][] getAndSetBaseQualitiesData() {
    final SAMRecord noQualsSam = basicSAMRecord();
    noQualsSam.setBaseQualities(null);
    final SAMRecord emptyQualsSam = basicSAMRecord();
    emptyQualsSam.setBaseQualities(new byte[0]);
    final Read noQualsGoogleRead = basicGoogleGenomicsRead();
    noQualsGoogleRead.setAlignedQuality(null);
    final Read emptyQualsGoogleRead = basicGoogleGenomicsRead();
    emptyQualsGoogleRead.setAlignedQuality(new ArrayList<>());
    return new Object[][] { { basicReadBackedBySam(), BASIC_READ_BASE_QUALITIES }, { basicReadBackedByGoogle(), BASIC_READ_BASE_QUALITIES }, { new SAMRecordToGATKReadAdapter(noQualsSam), new byte[0] }, { new SAMRecordToGATKReadAdapter(emptyQualsSam), new byte[0] }, { new GoogleGenomicsReadToGATKReadAdapter(noQualsGoogleRead), new byte[0] }, { new GoogleGenomicsReadToGATKReadAdapter(emptyQualsGoogleRead), new byte[0] } };
}
Also used : Read(com.google.api.services.genomics.model.Read) DataProvider(org.testng.annotations.DataProvider)

Example 4 with Read

use of com.google.api.services.genomics.model.Read in project gatk by broadinstitute.

the class GATKReadAdaptersUnitTest method getAndSetFragmentLengthData.

@DataProvider(name = "GetAndSetFragmentLengthData")
public Object[][] getAndSetFragmentLengthData() {
    final SAMRecord samWithISize = basicSAMRecord();
    samWithISize.setInferredInsertSize(120);
    final Read googleReadWithFragmentLength = basicGoogleGenomicsRead();
    googleReadWithFragmentLength.setFragmentLength(120);
    return new Object[][] { { basicReadBackedBySam(), 0 }, { basicReadBackedByGoogle(), 0 }, { new SAMRecordToGATKReadAdapter(samWithISize), 120 }, { new GoogleGenomicsReadToGATKReadAdapter(googleReadWithFragmentLength), 120 } };
}
Also used : Read(com.google.api.services.genomics.model.Read) DataProvider(org.testng.annotations.DataProvider)

Example 5 with Read

use of com.google.api.services.genomics.model.Read in project gatk by broadinstitute.

the class GATKReadAdaptersUnitTest method getAndSetNameData.

@DataProvider(name = "GetAndSetNameData")
public Object[][] getAndSetNameData() {
    final SAMRecord namelessSam = basicSAMRecord();
    namelessSam.setReadName(null);
    final Read namelessGoogleRead = basicGoogleGenomicsRead();
    namelessGoogleRead.setFragmentName(null);
    return new Object[][] { { basicReadBackedBySam(), BASIC_READ_NAME }, { basicReadBackedByGoogle(), BASIC_READ_NAME }, { new SAMRecordToGATKReadAdapter(namelessSam), null }, { new GoogleGenomicsReadToGATKReadAdapter(namelessGoogleRead), null } };
}
Also used : Read(com.google.api.services.genomics.model.Read) DataProvider(org.testng.annotations.DataProvider)

Aggregations

Read (com.google.api.services.genomics.model.Read)25 DataProvider (org.testng.annotations.DataProvider)20 Position (com.google.api.services.genomics.model.Position)5 LinearAlignment (com.google.api.services.genomics.model.LinearAlignment)2 UnmodifiableCollectionsSerializer (de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer)1 SAMFileHeader (htsjdk.samtools.SAMFileHeader)1 SAMRecord (htsjdk.samtools.SAMRecord)1 PairedEnds (org.broadinstitute.hellbender.utils.read.markduplicates.PairedEnds)1