Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SAMFileHeader #2323

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ import org.bdgenomics.adam.ds.OutFormatter
import org.bdgenomics.formats.avro.Alignment
import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer
import java.io.{ BufferedReader, InputStreamReader }
import org.bdgenomics.adam.ds._

/**
* An OutFormatter that automatically infers whether the piped input is SAM or
* BAM. Autodetecting streamed CRAM is not currently supported.
*/
case class AnySAMOutFormatter(stringency: ValidationStringency) extends OutFormatter[Alignment] {
case class AnySAMOutFormatter(stringency: ValidationStringency, header: SAMFileHeader) extends OutFormatter[Alignment] {

def this() = this(ValidationStringency.STRICT)
def this() = this(ValidationStringency.STRICT, new SAMFileHeader())

/**
* Reads alignments from an input stream. Autodetects SAM/BAM format.
Expand All @@ -46,6 +48,12 @@ case class AnySAMOutFormatter(stringency: ValidationStringency) extends OutForma
.validationStringency(stringency)
.open(SamInputResource.of(is))

//copy reader header
val r_header = reader.getFileHeader()
header.setSequenceDictionary(r_header.getSequenceDictionary())
header.setReadGroups(r_header.getReadGroups())
header.setProgramRecords(r_header.getProgramRecords())

SAMIteratorConverter(reader)
}
}
Expand Down