Skip to content

Commit

Permalink
Use adam-core-spark2_2.12:0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite committed Sep 17, 2019
1 parent 4180c0d commit 560963b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ dependencies {
compile 'com.thoughtworks.paranamer:paranamer:2.8'

compile 'org.bdgenomics.bdg-formats:bdg-formats:0.5.0'
compile('org.bdgenomics.adam:adam-core-spark2_2.11:0.20.0') {
compile('org.bdgenomics.adam:adam-core-spark2_2.12:0.28.0') {
exclude group: 'org.slf4j'
exclude group: 'org.apache.hadoop'
exclude group: 'org.scala-lang'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.broadcast.Broadcast;
import org.bdgenomics.adam.models.RecordGroupDictionary;
import org.bdgenomics.adam.models.ReadGroupDictionary;
import org.bdgenomics.adam.models.SequenceDictionary;
import org.bdgenomics.formats.avro.AlignmentRecord;
import org.broadinstitute.hellbender.exceptions.GATKException;
Expand Down Expand Up @@ -157,7 +157,7 @@ private static void writeReadsADAM(
final JavaSparkContext ctx, final String outputFile, final JavaRDD<SAMRecord> reads,
final SAMFileHeader header) throws IOException {
final SequenceDictionary seqDict = SequenceDictionary.fromSAMSequenceDictionary(header.getSequenceDictionary());
final RecordGroupDictionary readGroups = RecordGroupDictionary.fromSAMHeader(header);
final ReadGroupDictionary readGroups = ReadGroupDictionary.fromSAMHeader(header);
final JavaPairRDD<Void, AlignmentRecord> rddAlignmentRecords =
reads.map(read -> {
read.setHeaderStrict(header);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
import org.bdgenomics.adam.models.ReferenceRegion;
import org.bdgenomics.adam.util.TwoBitFile;
import org.bdgenomics.adam.util.TwoBitRecord;
import org.bdgenomics.formats.avro.Strand;
import org.bdgenomics.utils.io.ByteAccess;
import org.broadinstitute.hellbender.utils.SimpleInterval;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.gcs.BucketUtils;
import org.broadinstitute.hellbender.utils.reference.ReferenceBases;
import scala.Tuple2;
import scala.collection.JavaConversions;
import scala.collection.immutable.IndexedSeq;

import java.io.IOException;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -39,7 +43,10 @@ public ReferenceTwoBitSparkSource( String referenceURL) throws IOException {
byte[] bytes = ByteStreams.toByteArray(BucketUtils.openFile(this.referenceURL));
ByteAccess byteAccess = new DirectFullByteArrayByteAccess(bytes);
this.twoBitFile = new TwoBitFile(byteAccess);
this.twoBitSeqEntries = JavaConversions.mapAsJavaMap(twoBitFile.seqRecords());
this.twoBitSeqEntries = new LinkedHashMap<>();
for (Tuple2<String, TwoBitRecord> pair: JavaConversions.seqAsJavaList(twoBitFile.seqRecords())) {
twoBitSeqEntries.put(pair._1, pair._2);
}
}

/**
Expand Down Expand Up @@ -74,7 +81,7 @@ private static ReferenceRegion simpleIntervalToReferenceRegion(SimpleInterval in
String contig = interval.getContig();
long start = interval.getGA4GHStart();
long end = interval.getGA4GHEnd();
return new ReferenceRegion(contig, start, end, null);
return new ReferenceRegion(contig, start, end, Strand.UNKNOWN);
}

private SimpleInterval cropIntervalAtContigEnd( final SimpleInterval interval ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import htsjdk.samtools.SAMFileHeader;
import htsjdk.samtools.SAMRecord;
import org.bdgenomics.adam.converters.AlignmentRecordConverter;
import org.bdgenomics.adam.models.RecordGroupDictionary;
import org.bdgenomics.adam.models.SAMFileHeaderWritable;
import org.bdgenomics.adam.models.ReadGroupDictionary;
import org.bdgenomics.formats.avro.AlignmentRecord;

/**
Expand All @@ -30,8 +29,8 @@ public final class BDGAlignmentRecordToGATKReadAdapter extends SAMRecordToGATKRe
private final AlignmentRecord alignmentRecord;

public BDGAlignmentRecordToGATKReadAdapter(final AlignmentRecord alignmentRecord, final SAMFileHeader header) {
super(new AlignmentRecordConverter().convert(alignmentRecord, SAMFileHeaderWritable.apply(header),
RecordGroupDictionary.fromSAMHeader(header)));
super(new AlignmentRecordConverter().convert(alignmentRecord, header,
ReadGroupDictionary.fromSAMHeader(header)));
this.alignmentRecord = alignmentRecord;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bdgenomics.formats.avro.AlignmentRecord;
import org.bdgenomics.adam.converters.SAMRecordConverter;
import org.bdgenomics.adam.models.SequenceDictionary;
import org.bdgenomics.adam.models.RecordGroupDictionary;
import org.bdgenomics.adam.models.ReadGroupDictionary;

/**
* Converts a GATKRead to a BDG AlignmentRecord
Expand All @@ -15,27 +15,27 @@ public class GATKReadToBDGAlignmentRecordConverter {

private SAMFileHeader header;
private SequenceDictionary dict;
private RecordGroupDictionary readGroups;
private ReadGroupDictionary readGroups;

public GATKReadToBDGAlignmentRecordConverter(SAMFileHeader header) {
this.header = header;
this.dict = SequenceDictionary.fromSAMSequenceDictionary(header.getSequenceDictionary());
this.readGroups = RecordGroupDictionary.fromSAMHeader(header);
this.readGroups = ReadGroupDictionary.fromSAMHeader(header);
}

public static AlignmentRecord convert( final GATKRead gatkRead, final SAMFileHeader header ) {
SequenceDictionary dict = SequenceDictionary.fromSAMSequenceDictionary(header.getSequenceDictionary());
RecordGroupDictionary readGroups = RecordGroupDictionary.fromSAMHeader(header);
ReadGroupDictionary readGroups = ReadGroupDictionary.fromSAMHeader(header);
return GATKReadToBDGAlignmentRecordConverter.convert(gatkRead, header, dict, readGroups);
}

public static AlignmentRecord convert(
final GATKRead gatkRead, final SAMFileHeader header, final SequenceDictionary dict, final RecordGroupDictionary readGroups ) {
final GATKRead gatkRead, final SAMFileHeader header, final SequenceDictionary dict, final ReadGroupDictionary readGroups ) {
return converter.convert(gatkRead.convertToSAMRecord(header));
}

public static AlignmentRecord convert(
final SAMRecord sam, final SequenceDictionary dict, final RecordGroupDictionary readGroups ) {
final SAMRecord sam, final SequenceDictionary dict, final ReadGroupDictionary readGroups ) {
return converter.convert(sam);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public Object[][] readPairsForToString() {

private static GATKRead basicReadBackedByADAMRecord(final SAMRecord sam) {
final AlignmentRecord record = new AlignmentRecord();
record.setContigName(sam.getContig());
record.setRecordGroupSample(sam.getReadGroup().getSample());
record.setReadName(sam.getReadName());
record.setSequence(new String(sam.getReadBases()));
record.setStart((long)sam.getAlignmentStart()-1); //ADAM records are 0-based
Expand Down

0 comments on commit 560963b

Please sign in to comment.