Skip to content

Commit

Permalink
Deprecate SAMFileHeaderWriteable.
Browse files Browse the repository at this point in the history
  • Loading branch information
heuermh committed Jun 12, 2019
1 parent 38973ae commit b58e2c7
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ class AlignmentRecordConverter extends Serializable {
* @return Returns the record converted to htsjdk format. Can be used for output to SAM/BAM.
*/
def convert(adamRecord: AlignmentRecord,
header: SAMFileHeaderWritable,
header: SAMFileHeader,
rgd: ReadGroupDictionary): SAMRecord = ConvertToSAMRecord.time {

// attach header
val builder: SAMRecord = new SAMRecord(header.header)
val builder: SAMRecord = new SAMRecord(header)

// set canonically necessary fields
builder.setReadName(adamRecord.getReadName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import org.bdgenomics.adam.rdd.ADAMContext
import org.bdgenomics.adam.rdd.read.AlignmentRecordDataset
import scala.collection.JavaConversions._

/**
* @deprecated no longer necessary, SAMFileHeader implements Serializable
*/
private[adam] object SAMFileHeaderWritable {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ sealed abstract class AlignmentRecordDataset extends AvroReadGroupGenomicDataset
header.setProgramRecords(pgRecords.asJava)

// broadcast for efficiency
val hdrBcast = rdd.context.broadcast(SAMFileHeaderWritable(header))
val hdrBcast = rdd.context.broadcast(header)

// map across RDD to perform conversion
val convertedRDD: RDD[SAMRecordWritable] = rdd.map(r => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ package org.bdgenomics.adam.rdd.read
import htsjdk.samtools.{ SAMFileHeader, SAMFileWriter }
import java.io.OutputStream
import org.bdgenomics.adam.converters.AlignmentRecordConverter
import org.bdgenomics.adam.models.{
ReadGroupDictionary,
SAMFileHeaderWritable
}
import org.bdgenomics.adam.models.ReadGroupDictionary
import org.bdgenomics.adam.rdd.{ InFormatter, InFormatterCompanion }
import org.bdgenomics.adam.sql.{ AlignmentRecord => AlignmentRecordProduct }
import org.bdgenomics.formats.avro.AlignmentRecord
Expand All @@ -35,7 +32,7 @@ import org.bdgenomics.formats.avro.AlignmentRecord
* @tparam T The type of the underlying InFormatter.
*/
trait AnySAMInFormatterCompanion[T <: AnySAMInFormatter[T]] extends InFormatterCompanion[AlignmentRecord, AlignmentRecordProduct, AlignmentRecordDataset, T] {
protected def makeFormatter(header: SAMFileHeaderWritable,
protected def makeFormatter(header: SAMFileHeader,
readGroups: ReadGroupDictionary,
converter: AlignmentRecordConverter): T

Expand All @@ -55,7 +52,7 @@ trait AnySAMInFormatterCompanion[T <: AnySAMInFormatter[T]] extends InFormatterC
header.setSortOrder(SAMFileHeader.SortOrder.coordinate)

// construct the in formatter
makeFormatter(SAMFileHeaderWritable(header), gDataset.readGroups, arc)
makeFormatter(header, gDataset.readGroups, arc)
}
}

Expand All @@ -69,7 +66,7 @@ trait AnySAMInFormatter[T <: AnySAMInFormatter[T]] extends InFormatter[Alignment
/**
* A serializable form of the SAM File Header.
*/
val header: SAMFileHeaderWritable
val header: SAMFileHeader

/**
* A dictionary describing the read groups these reads are from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,35 @@
package org.bdgenomics.adam.rdd.read

import htsjdk.samtools.{
SAMFileHeader,
SAMFileWriter,
SAMFileWriterFactory
}
import java.io.OutputStream
import org.bdgenomics.adam.converters.AlignmentRecordConverter
import org.bdgenomics.adam.models.{
ReadGroupDictionary,
SAMFileHeaderWritable
}
import org.bdgenomics.adam.models.ReadGroupDictionary

/**
* InFormatter companion for building an InFormatter that streams BAM.
*/
object BAMInFormatter extends AnySAMInFormatterCompanion[BAMInFormatter] {

protected def makeFormatter(header: SAMFileHeaderWritable,
protected def makeFormatter(header: SAMFileHeader,
readGroups: ReadGroupDictionary,
converter: AlignmentRecordConverter): BAMInFormatter = {
BAMInFormatter(header, readGroups, converter)
}
}

case class BAMInFormatter private (
header: SAMFileHeaderWritable,
header: SAMFileHeader,
readGroups: ReadGroupDictionary,
converter: AlignmentRecordConverter) extends AnySAMInFormatter[BAMInFormatter] {

protected val companion = BAMInFormatter

protected def makeWriter(os: OutputStream): SAMFileWriter = {
new SAMFileWriterFactory()
.makeBAMWriter(header.header, true, os)
.makeBAMWriter(header, true, os)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@
package org.bdgenomics.adam.rdd.read

import htsjdk.samtools.{
SAMFileHeader,
SAMFileWriter,
SAMFileWriterFactory
}
import java.io.OutputStream
import org.bdgenomics.adam.converters.AlignmentRecordConverter
import org.bdgenomics.adam.models.{
ReadGroupDictionary,
SAMFileHeaderWritable
}
import org.bdgenomics.adam.models.ReadGroupDictionary

/**
* InFormatter companion for building an InFormatter that streams SAM.
*/
object SAMInFormatter extends AnySAMInFormatterCompanion[SAMInFormatter] {

protected def makeFormatter(header: SAMFileHeaderWritable,
protected def makeFormatter(header: SAMFileHeader,
readGroups: ReadGroupDictionary,
converter: AlignmentRecordConverter): SAMInFormatter = {
SAMInFormatter(header, readGroups, converter)
}
}

case class SAMInFormatter private (
header: SAMFileHeaderWritable,
header: SAMFileHeader,
readGroups: ReadGroupDictionary,
converter: AlignmentRecordConverter) extends AnySAMInFormatter[SAMInFormatter] {

Expand All @@ -53,6 +51,6 @@ case class SAMInFormatter private (

protected def makeWriter(os: OutputStream): SAMFileWriter = {
new SAMFileWriterFactory()
.makeSAMWriter(header.header, true, os)
.makeSAMWriter(header, true, os)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ class ADAMKryoRegistrator extends KryoRegistrator with Logging {
kryo.register(classOf[htsjdk.samtools.CigarElement])
kryo.register(classOf[htsjdk.samtools.CigarOperator])
kryo.register(classOf[htsjdk.samtools.Cigar])
kryo.register(classOf[htsjdk.samtools.SAMProgramRecord])
kryo.register(classOf[htsjdk.samtools.SAMReadGroupRecord])
kryo.register(classOf[htsjdk.samtools.SAMSequenceDictionary])
kryo.register(classOf[htsjdk.samtools.SAMFileHeader])
kryo.register(classOf[htsjdk.samtools.SAMSequenceRecord])
registerByName(kryo, "htsjdk.samtools.SAMFileHeader$GroupOrder")
registerByName(kryo, "htsjdk.samtools.SAMFileHeader$SortOrder")

// htsjdk.variant.vcf
kryo.register(classOf[htsjdk.variant.vcf.VCFContigHeaderLine])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
*/
package org.bdgenomics.adam.converters

import htsjdk.samtools.SamReaderFactory
import htsjdk.samtools.{
SAMFileHeader,
SamReaderFactory
}
import java.io.File
import org.bdgenomics.adam.models.{
ReadGroupDictionary,
ReadGroup,
SAMFileHeaderWritable,
SequenceDictionary,
SequenceRecord
}
Expand Down Expand Up @@ -79,8 +81,7 @@ class AlignmentRecordConverterSuite extends FunSuite {

// convert read
val toSAM = adamRecordConverter.convert(adamRead,
SAMFileHeaderWritable(adamRecordConverter.createSAMHeader(dict,
readGroups)),
adamRecordConverter.createSAMHeader(dict, readGroups),
readGroups)

// validate conversion
Expand Down Expand Up @@ -122,8 +123,7 @@ class AlignmentRecordConverterSuite extends FunSuite {

// convert read
val toSAM = adamRecordConverter.convert(adamRead,
SAMFileHeaderWritable(adamRecordConverter.createSAMHeader(dict,
readGroups)),
adamRecordConverter.createSAMHeader(dict, readGroups),
readGroups)

// validate conversion
Expand Down

0 comments on commit b58e2c7

Please sign in to comment.