Skip to content

Commit

Permalink
Merge pull request #586 from andrewmchen/sm-bam-attribute-fix
Browse files Browse the repository at this point in the history
[ADAM-452] Fixes SM attribute on ADAM to BAM conversion.
  • Loading branch information
fnothaft committed Feb 24, 2015
2 parents 293407f + d313e6b commit 94f4841
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ class AlignmentRecordConverter extends Serializable {
.foreach(v => builder.setAttribute("LB", v.toString))
Option(adamRecord.getRecordGroupPlatformUnit)
.foreach(v => builder.setAttribute("PU", v.toString))
Option(adamRecord.getRecordGroupSample)
.foreach(v => builder.setAttribute("SM", v.toString))

// set the reference name, and alignment position, for mate
Option(adamRecord.getMateContig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.bdgenomics.adam.converters
import org.bdgenomics.formats.avro.{ AlignmentRecord, Contig }
import org.bdgenomics.adam.models.{
RecordGroupDictionary,
RecordGroup,
SAMFileHeaderWritable,
SequenceDictionary,
SequenceRecord
Expand Down Expand Up @@ -52,7 +53,8 @@ class AlignmentRecordConverterSuite extends FunSuite {
val adamRead = make_read(3L, "2M3D2M", "2^AAA2", 4)

// add reference details
adamRead.setRecordGroupName("testname")
adamRead.setRecordGroupName("record_group")
adamRead.setRecordGroupSample("sample")
adamRead.setContig(Contig.newBuilder()
.setContigName("referencetest")
.build())
Expand All @@ -66,7 +68,10 @@ class AlignmentRecordConverterSuite extends FunSuite {
// make sequence dictionary
val seqRecForDict = SequenceRecord("referencetest", 5, "test://chrom1")
val dict = SequenceDictionary(seqRecForDict)
val readGroups = new RecordGroupDictionary(Seq())

//make read group dictionary
val readGroup = new RecordGroup(adamRead.getRecordGroupSample(), adamRead.getRecordGroupName())
val readGroups = new RecordGroupDictionary(Seq(readGroup))

// convert read
val toSAM = adamRecordConverter.convert(adamRead,
Expand All @@ -86,6 +91,10 @@ class AlignmentRecordConverterSuite extends FunSuite {
assert(toSAM.getAttribute("MD") === "2^AAA2")
assert(toSAM.getIntegerAttribute("OP") === 13)
assert(toSAM.getStringAttribute("OC") === "2^AAA3")
//make sure that we didn't set the SM attribute.
//issue #452 https://github.com/bigdatagenomics/adam/issues/452
assert(toSAM.getAttribute("SM") === null)
assert(toSAM.getHeader().getReadGroup("record_group").getSample() === "sample")
}

test("convert a read to fastq") {
Expand Down

0 comments on commit 94f4841

Please sign in to comment.