Search in sources :

Example 21 with Read

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

the class GATKReadAdaptersUnitTest method getReadNumberOfUnpairedReadData.

@DataProvider(name = "GetReadNumberOfUnpairedReadData")
public Object[][] getReadNumberOfUnpairedReadData() {
    SAMRecord unpairedSAM = basicSAMRecord();
    unpairedSAM.setFirstOfPairFlag(true);
    unpairedSAM.setSecondOfPairFlag(false);
    unpairedSAM.setReadPairedFlag(false);
    SAMRecord unpairedSAM2 = basicSAMRecord();
    unpairedSAM2.setSecondOfPairFlag(true);
    unpairedSAM2.setFirstOfPairFlag(false);
    unpairedSAM2.setReadPairedFlag(false);
    Read unpairedGoogleRead = basicGoogleGenomicsRead();
    unpairedGoogleRead.setReadNumber(0);
    unpairedGoogleRead.setNumberReads(1);
    Read unpairedGoogleRead2 = basicGoogleGenomicsRead();
    unpairedGoogleRead2.setReadNumber(1);
    unpairedGoogleRead2.setNumberReads(1);
    return new Object[][] { { new SAMRecordToGATKReadAdapter(unpairedSAM) }, { new SAMRecordToGATKReadAdapter(unpairedSAM2) }, { new GoogleGenomicsReadToGATKReadAdapter(unpairedGoogleRead) }, { new GoogleGenomicsReadToGATKReadAdapter(unpairedGoogleRead2) } };
}
Also used : Read(com.google.api.services.genomics.model.Read) DataProvider(org.testng.annotations.DataProvider)

Example 22 with Read

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

the class GATKReadAdaptersUnitTest method isReverseStrandData.

@DataProvider(name = "IsReverseStrandData")
public Object[][] isReverseStrandData() {
    SAMRecord reverseStrandSam = basicSAMRecord();
    reverseStrandSam.setReadNegativeStrandFlag(true);
    Read reverseStrandGoogleRead = basicGoogleGenomicsRead();
    reverseStrandGoogleRead.getAlignment().getPosition().setReverseStrand(true);
    return new Object[][] { { basicReadBackedBySam(), false }, { basicReadBackedByGoogle(), false }, { new SAMRecordToGATKReadAdapter(reverseStrandSam), true }, { new GoogleGenomicsReadToGATKReadAdapter(reverseStrandGoogleRead), true } };
}
Also used : Read(com.google.api.services.genomics.model.Read) DataProvider(org.testng.annotations.DataProvider)

Example 23 with Read

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

the class GATKReadAdaptersUnitTest method getUnclippedStartAndEndData.

@DataProvider(name = "GetUnclippedStartAndEndData")
public Object[][] getUnclippedStartAndEndData() {
    final SAMRecord softClippedSam = basicSAMRecord();
    softClippedSam.setCigarString("1S2M1S");
    final SAMRecord hardClippedSam = basicSAMRecord();
    hardClippedSam.setCigarString("3H2M2H");
    final Read softClippedGoogleRead = basicGoogleGenomicsRead();
    softClippedGoogleRead.getAlignment().setCigar(CigarConversionUtils.convertSAMCigarToCigarUnitList(TextCigarCodec.decode("1S2M1S")));
    final Read hardClippedGoogleRead = basicGoogleGenomicsRead();
    hardClippedGoogleRead.getAlignment().setCigar(CigarConversionUtils.convertSAMCigarToCigarUnitList(TextCigarCodec.decode("3H2M2H")));
    return new Object[][] { { new SAMRecordToGATKReadAdapter(softClippedSam), BASIC_READ_START - 1, BASIC_READ_START + 2 }, { new SAMRecordToGATKReadAdapter(hardClippedSam), BASIC_READ_START - 3, BASIC_READ_START + 3 }, { new GoogleGenomicsReadToGATKReadAdapter(softClippedGoogleRead), BASIC_READ_START - 1, BASIC_READ_START + 2 }, { new GoogleGenomicsReadToGATKReadAdapter(hardClippedGoogleRead), BASIC_READ_START - 3, BASIC_READ_START + 3 } };
}
Also used : Read(com.google.api.services.genomics.model.Read) DataProvider(org.testng.annotations.DataProvider)

Example 24 with Read

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

the class GATKRegistrator method registerClasses.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void registerClasses(Kryo kryo) {
    // JsonSerializer is needed for the Google Genomics classes like Read and Reference.
    kryo.register(Read.class, new JsonSerializer<Read>());
    //relatively inefficient serialization of Collections created with Collections.nCopies(), without this
    //any Collection created with Collections.nCopies fails to serialize at run time
    kryo.register(Collections.nCopies(2, "").getClass(), new FieldSerializer<>(kryo, Collections.nCopies(2, "").getClass()));
    // htsjdk.variant.variantcontext.CommonInfo has a Map<String, Object> that defaults to
    // a Collections.unmodifiableMap. This can't be handled by the version of kryo used in Spark, it's fixed
    // in newer versions (3.0.x), but we can't use those because of incompatibility with Spark. We just include the
    // fix here.
    // We are tracking this issue with (#874)
    kryo.register(Collections.unmodifiableMap(Collections.EMPTY_MAP).getClass(), new UnmodifiableCollectionsSerializer());
    kryo.register(Collections.unmodifiableList(Collections.EMPTY_LIST).getClass(), new UnmodifiableCollectionsSerializer());
    kryo.register(SAMRecordToGATKReadAdapter.class, new SAMRecordToGATKReadAdapterSerializer());
    kryo.register(SAMRecord.class, new SAMRecordSerializer());
    //register to avoid writing the full name of this class over and over
    kryo.register(PairedEnds.class, new FieldSerializer<>(kryo, PairedEnds.class));
    // register the ADAM data types using Avro serialization, including:
    //     AlignmentRecord
    //     Genotype
    //     Variant
    //     DatabaseVariantAnnotation
    //     NucleotideContigFragment
    //     Contig
    //     StructuralVariant
    //     VariantCallingAnnotations
    //     VariantEffect
    //     DatabaseVariantAnnotation
    //     Dbxref
    //     Feature
    //     ReferencePosition
    //     ReferencePositionPair
    //     SingleReadBucket
    //     IndelRealignmentTarget
    //     TargetSet
    //     ZippedTargetSet
    ADAMregistrator.registerClasses(kryo);
}
Also used : Read(com.google.api.services.genomics.model.Read) UnmodifiableCollectionsSerializer(de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer) PairedEnds(org.broadinstitute.hellbender.utils.read.markduplicates.PairedEnds)

Example 25 with Read

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

the class ArtificialReadUtils method createGoogleBackedRead.

/**
     * Creates an artificial GATKRead backed by a Google Genomics read.
     *
     * The read will consist of the specified number of Q30 'A' bases, and will be
     * mapped to the specified contig at the specified start position.
     *
     * @param name name of the new read
     * @param contig contig the new read is mapped to
     * @param start start position of the new read
     * @param length number of bases in the new read
     * @return an artificial GATKRead backed by a Google Genomics read.
     */
public static GATKRead createGoogleBackedRead(final String name, final String contig, final int start, final int length) {
    final byte[] bases = Utils.dupBytes((byte) 'A', length);
    final byte[] quals = Utils.dupBytes((byte) 30, length);
    final Read googleRead = createArtificialGoogleGenomicsRead(name, contig, start, bases, quals, length + "M");
    return new GoogleGenomicsReadToGATKReadAdapter(googleRead);
}
Also used : Read(com.google.api.services.genomics.model.Read)

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