From d2c19bda20910a35c8430d55bf0ebf82a2f1ff3e Mon Sep 17 00:00:00 2001 From: hxdhan Date: Wed, 23 Jun 2021 11:21:48 +0800 Subject: [PATCH] add SAMFileHeader --- .../bdgenomics/adam/ds/read/AnySAMOutFormatter.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/adam-core/src/main/scala/org/bdgenomics/adam/ds/read/AnySAMOutFormatter.scala b/adam-core/src/main/scala/org/bdgenomics/adam/ds/read/AnySAMOutFormatter.scala index bf61a88f4a..f55b54a678 100644 --- a/adam-core/src/main/scala/org/bdgenomics/adam/ds/read/AnySAMOutFormatter.scala +++ b/adam-core/src/main/scala/org/bdgenomics/adam/ds/read/AnySAMOutFormatter.scala @@ -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. @@ -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) } }