Skip to content

Commit

Permalink
[ADAM-1570] Upgrade to bdg-formats 0.11.1.
Browse files Browse the repository at this point in the history
Resolves #1570.
  • Loading branch information
fnothaft committed Jun 22, 2017
1 parent 412d092 commit 8cf09f6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ class VariantContextConverter(
*/
private def jFloat(f: Float): java.lang.Float = f

/**
* Converts a Scala double to a Java double.
*
* @param f Scala double precision floating point value.
* @return Java double precision floating point value.
*/
private def jDouble(f: Double): java.lang.Double = f

/**
* Converts a GATK variant context into one or more ADAM variant context(s).
*
Expand Down Expand Up @@ -818,7 +826,7 @@ class VariantContextConverter(
val pl = g.getPL
try {
val likelihoods = gIndices.map(idx => {
jFloat(PhredUtils.phredToLogProbability(pl(idx)).toFloat)
jDouble(PhredUtils.phredToLogProbability(pl(idx)))
}).toList
gb.setGenotypeLikelihoods(likelihoods)
} catch {
Expand All @@ -838,7 +846,7 @@ class VariantContextConverter(
if (g.hasPL) {
val pl = g.getPL
gb.setNonReferenceLikelihoods(gIndices.map(idx => {
jFloat(PhredUtils.phredToLogProbability(pl(idx)).toFloat)
jDouble(PhredUtils.phredToLogProbability(pl(idx)))
}).toList)
} else {
gb
Expand Down Expand Up @@ -968,8 +976,8 @@ class VariantContextConverter(
plCalculator(copyNumber)
}

private[converters] def nonRefPls(gls: java.util.List[java.lang.Float],
nls: java.util.List[java.lang.Float]): Array[Int] = {
private[converters] def nonRefPls(gls: java.util.List[java.lang.Double],
nls: java.util.List[java.lang.Double]): Array[Int] = {
require(gls.length == nls.length,
"Genotype likelihoods (%s) and non-reference likelihoods (%s) disagree on copy number".format(
gls.mkString(","), nls.mkString(",")))
Expand All @@ -979,12 +987,12 @@ class VariantContextConverter(
val array = Array.fill(elements) { Int.MinValue }

(0 to copyNumber).foreach(idx => {
array(idx) = PhredUtils.logProbabilityToPhred(gls.get(idx).toDouble)
array(idx) = PhredUtils.logProbabilityToPhred(gls.get(idx))
})

var cnIdx = copyNumber + 1
(1 to copyNumber).foreach(idx => {
array(cnIdx + 1) = PhredUtils.logProbabilityToPhred(nls.get(idx).toDouble)
array(cnIdx + 1) = PhredUtils.logProbabilityToPhred(nls.get(idx))
cnIdx += (copyNumber - idx)
})

Expand All @@ -1004,11 +1012,11 @@ class VariantContextConverter(
}
gb.noPL
} else {
gb.PL(nls.map(l => PhredUtils.logProbabilityToPhred(l.toDouble))
gb.PL(nls.map(l => PhredUtils.logProbabilityToPhred(l))
.toArray)
}
} else if (nls.isEmpty) {
gb.PL(gls.map(l => PhredUtils.logProbabilityToPhred(l.toDouble))
gb.PL(gls.map(l => PhredUtils.logProbabilityToPhred(l))
.toArray)
} else {
gb.PL(nonRefPls(gls, nls))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@
chr22 16157521 . C <NON_REF> . . END=16157602 GT:DP:GQ:MIN_DP:PL 0/0:4:9:2:0,0,45
chr22 16157603 . G C,<NON_REF> . . DP=1;MLEAC=1;MLEAF=0.5;MQ=59.0;MQ0=0 GT:AD:DP:GQ:PL 1/1:0,1:1:3:41,3,0,-2147483648,41,41
chr22 16157604 . G <NON_REF> . . END=16157639 GT:DP:GQ:MIN_DP:PL 0/0:2:0:1:0,0,0
chr22 18030096 . TAAA T,<NON_REF> . . BaseQRankSum=-0.133;ClippingRankSum=-1.438;DP=114;MLEAC=0;MLEAF=0.0;MQ=69.72;MQ0=0;MQRankSum=-0.686;ReadPosRankSum=-0.013 GT:AD:DP:GQ:PL ./.:13,3:50:86:2147483647,2147483647,2147483647,-2147483648,2147483647,2147483647
chr22 18030096 . TAAA TA,<NON_REF> . . BaseQRankSum=-0.133;ClippingRankSum=-1.438;DP=114;MLEAC=1;MLEAF=0.5;MQ=69.72;MQ0=0;MQRankSum=-0.686;ReadPosRankSum=-0.013 GT:AD:DP:GQ:PL 1/.:13,17:50:86:2147483647,86,2147483647,-2147483648,2147483647,2147483647
chr22 18030096 . TAAA TAA,<NON_REF> . . BaseQRankSum=-0.133;ClippingRankSum=-1.438;DP=114;MLEAC=1;MLEAF=0.5;MQ=69.72;MQ0=0;MQRankSum=-0.686;ReadPosRankSum=-0.013 GT:AD:DP:GQ:PL ./1:13,17:50:86:2147483647,137,281,-2147483648,2147483647,2147483647
chr22 18030096 . TAAA T,<NON_REF> . . BaseQRankSum=-0.133;ClippingRankSum=-1.438;DP=114;MLEAC=0;MLEAF=0.0;MQ=69.72;MQ0=0;MQRankSum=-0.686;ReadPosRankSum=-0.013 GT:AD:DP:GQ:PL ./.:13,3:50:86:602,508,1628,-2147483648,467,659
chr22 18030096 . TAAA TA,<NON_REF> . . BaseQRankSum=-0.133;ClippingRankSum=-1.438;DP=114;MLEAC=1;MLEAF=0.5;MQ=69.72;MQ0=0;MQRankSum=-0.686;ReadPosRankSum=-0.013 GT:AD:DP:GQ:PL 1/.:13,17:50:86:602,86,553,-2147483648,467,659
chr22 18030096 . TAAA TAA,<NON_REF> . . BaseQRankSum=-0.133;ClippingRankSum=-1.438;DP=114;MLEAC=1;MLEAF=0.5;MQ=69.72;MQ0=0;MQRankSum=-0.686;ReadPosRankSum=-0.013 GT:AD:DP:GQ:PL ./1:13,17:50:86:602,137,281,-2147483648,467,659
12 changes: 6 additions & 6 deletions adam-core/src/test/resources/sorted.lex.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
##contig=<ID=2,length=249250621>
##contig=<ID=13,length=249250621>
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA12878 NA12891 NA12892
1 14397 . CTGT C . IndelQD AC=2;AF=0.333;AN=6;BaseQRankSum=1.8;ClippingRankSum=0.138;DP=69;FS=7.786;MLEAC=2;MLEAF=0.333;MQ=26.84;MQ0=0;MQRankSum=-1.906;QD=1.55;ReadPosRankSum=0.384 GT:AD:DP:FT:GQ:PL 0/1:16,4:20:rd:99:120,0,2147483647 0/1:8,2:10:dp;rd:60:60,0,414 0/0:39,0:39:PASS:99:0,116,2147483647
1 14522 . G A . VQSRTrancheSNP99.95to100.00 AC=2;AF=0.333;AN=6;BaseQRankSum=2.044;ClippingRankSum=-2.196;DP=48;FS=13.179;MLEAC=2;MLEAF=0.333;MQ=25.89;MQ0=0;MQRankSum=-0.063;QD=8.87;ReadPosRankSum=0.952;VQSLOD=-3.333;culprit=MQ GT:AD:DP:FT:GQ:PL 0/1:10,5:15:dp:99:99,0,2147483647 0/1:2,5:7:dp;rd:34:128,0,34 0/0:26,0:26:PASS:78:0,78,2147483647
1 63735 rs201888535 CCTA C . PASS AC=1;AF=0.167;AN=6;BaseQRankSum=1.138;ClippingRankSum=0.448;DB;DP=176;FS=13.597;MLEAC=1;MLEAF=0.167;MQ=31.06;MQ0=0;MQRankSum=0.636;QD=9.98;ReadPosRankSum=-1.18 GT:AD:DP:FT:GQ:PL 0/0:27,0:27:PASS:79:0,79,2147483647 0/0:40,0:40:PASS:99:0,117,2147483647 0/1:23,74:97:rd:99:2147483647,0,2147483647
13 752721 rs3131972 A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL 1/1:0,27:27:PASS:81:2147483647,81,0 1/1:0,19:19:dp:57:2147483647,57,0 1/1:0,22:22:PASS:66:2147483647,66,0
13 752791 . A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL:SB 1/1:0,27:27:PASS:81:2147483647,81,0:0,1,2,3 1/1:0,19:19:dp:57:2147483647,57,0:4,5,6,7 1/1:0,22:22:PASS:66:2147483647,66,0:2,3,4,5
2 19190 . GC G . PASS AC=3;AF=0.5;AN=6;BaseQRankSum=4.157;ClippingRankSum=3.666;DP=74;FS=37.037;MLEAC=3;MLEAF=0.5;MQ=22.26;MQ0=0;MQRankSum=0.195;QD=16.04;ReadPosRankSum=-4.072 GT:AD:DP:FT:GQ:PL 0/1:8,14:22:PASS:99:416,0,2147483647 0/1:18,13:31:PASS:99:353,0,2147483647 0/1:5,15:20:rd:99:2147483647,0,107
1 14397 . CTGT C . IndelQD AC=2;AF=0.333;AN=6;BaseQRankSum=1.8;ClippingRankSum=0.138;DP=69;FS=7.786;MLEAC=2;MLEAF=0.333;MQ=26.84;MQ0=0;MQRankSum=-1.906;QD=1.55;ReadPosRankSum=0.384 GT:AD:DP:FT:GQ:PL 0/1:16,4:20:rd:99:120,0,827 0/1:8,2:10:dp;rd:60:60,0,414 0/0:39,0:39:PASS:99:0,116,2114
1 14522 . G A . VQSRTrancheSNP99.95to100.00 AC=2;AF=0.333;AN=6;BaseQRankSum=2.044;ClippingRankSum=-2.196;DP=48;FS=13.179;MLEAC=2;MLEAF=0.333;MQ=25.89;MQ0=0;MQRankSum=-0.063;QD=8.87;ReadPosRankSum=0.952;VQSLOD=-3.333;culprit=MQ GT:AD:DP:FT:GQ:PL 0/1:10,5:15:dp:99:99,0,2147483647 0/1:2,5:7:dp;rd:34:128,0,34 0/0:26,0:26:PASS:78:0,78,783
1 63735 rs201888535 CCTA C . PASS AC=1;AF=0.167;AN=6;BaseQRankSum=1.138;ClippingRankSum=0.448;DB;DP=176;FS=13.597;MLEAC=1;MLEAF=0.167;MQ=31.06;MQ0=0;MQRankSum=0.636;QD=9.98;ReadPosRankSum=-1.18 GT:AD:DP:FT:GQ:PL 0/0:27,0:27:PASS:79:0,79,1425 0/0:40,0:40:PASS:99:0,117,2120 0/1:23,74:97:rd:99:3034,0,942
13 752721 rs3131972 A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL 1/1:0,27:27:PASS:81:1021,81,0 1/1:0,19:19:dp:57:661,57,0 1/1:0,22:22:PASS:66:831,66,0
13 752791 . A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL:SB 1/1:0,27:27:PASS:81:1021,81,0:0,1,2,3 1/1:0,19:19:dp:57:661,57,0:4,5,6,7 1/1:0,22:22:PASS:66:831,66,0:2,3,4,5
2 19190 . GC G . PASS AC=3;AF=0.5;AN=6;BaseQRankSum=4.157;ClippingRankSum=3.666;DP=74;FS=37.037;MLEAC=3;MLEAF=0.5;MQ=22.26;MQ0=0;MQRankSum=0.195;QD=16.04;ReadPosRankSum=-4.072 GT:AD:DP:FT:GQ:PL 0/1:8,14:22:PASS:99:416,0,2147483647 0/1:18,13:31:PASS:99:353,0,503 0/1:5,15:20:rd:99:457,0,107
12 changes: 6 additions & 6 deletions adam-core/src/test/resources/sorted.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
##contig=<ID=2,length=249250621>
##contig=<ID=13,length=249250621>
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA12878 NA12891 NA12892
1 14397 . CTGT C . IndelQD AC=2;AF=0.333;AN=6;BaseQRankSum=1.8;ClippingRankSum=0.138;DP=69;FS=7.786;MLEAC=2;MLEAF=0.333;MQ=26.84;MQ0=0;MQRankSum=-1.906;QD=1.55;ReadPosRankSum=0.384 GT:AD:DP:FT:GQ:PL 0/1:16,4:20:rd:99:120,0,2147483647 0/1:8,2:10:dp;rd:60:60,0,414 0/0:39,0:39:PASS:99:0,116,2147483647
1 14522 . G A . VQSRTrancheSNP99.95to100.00 AC=2;AF=0.333;AN=6;BaseQRankSum=2.044;ClippingRankSum=-2.196;DP=48;FS=13.179;MLEAC=2;MLEAF=0.333;MQ=25.89;MQ0=0;MQRankSum=-0.063;QD=8.87;ReadPosRankSum=0.952;VQSLOD=-3.333;culprit=MQ GT:AD:DP:FT:GQ:PL 0/1:10,5:15:dp:99:99,0,2147483647 0/1:2,5:7:dp;rd:34:128,0,34 0/0:26,0:26:PASS:78:0,78,2147483647
1 63735 rs201888535 CCTA C . PASS AC=1;AF=0.167;AN=6;BaseQRankSum=1.138;ClippingRankSum=0.448;DB;DP=176;FS=13.597;MLEAC=1;MLEAF=0.167;MQ=31.06;MQ0=0;MQRankSum=0.636;QD=9.98;ReadPosRankSum=-1.18 GT:AD:DP:FT:GQ:PL 0/0:27,0:27:PASS:79:0,79,2147483647 0/0:40,0:40:PASS:99:0,117,2147483647 0/1:23,74:97:rd:99:2147483647,0,2147483647
2 19190 . GC G . PASS AC=3;AF=0.5;AN=6;BaseQRankSum=4.157;ClippingRankSum=3.666;DP=74;FS=37.037;MLEAC=3;MLEAF=0.5;MQ=22.26;MQ0=0;MQRankSum=0.195;QD=16.04;ReadPosRankSum=-4.072 GT:AD:DP:FT:GQ:PL 0/1:8,14:22:PASS:99:416,0,2147483647 0/1:18,13:31:PASS:99:353,0,2147483647 0/1:5,15:20:rd:99:2147483647,0,107
13 752721 rs3131972 A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL 1/1:0,27:27:PASS:81:2147483647,81,0 1/1:0,19:19:dp:57:2147483647,57,0 1/1:0,22:22:PASS:66:2147483647,66,0
13 752791 . A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL:SB 1/1:0,27:27:PASS:81:2147483647,81,0:0,1,2,3 1/1:0,19:19:dp:57:2147483647,57,0:4,5,6,7 1/1:0,22:22:PASS:66:2147483647,66,0:2,3,4,5
1 14397 . CTGT C . IndelQD AC=2;AF=0.333;AN=6;BaseQRankSum=1.8;ClippingRankSum=0.138;DP=69;FS=7.786;MLEAC=2;MLEAF=0.333;MQ=26.84;MQ0=0;MQRankSum=-1.906;QD=1.55;ReadPosRankSum=0.384 GT:AD:DP:FT:GQ:PL 0/1:16,4:20:rd:99:120,0,827 0/1:8,2:10:dp;rd:60:60,0,414 0/0:39,0:39:PASS:99:0,116,2114
1 14522 . G A . VQSRTrancheSNP99.95to100.00 AC=2;AF=0.333;AN=6;BaseQRankSum=2.044;ClippingRankSum=-2.196;DP=48;FS=13.179;MLEAC=2;MLEAF=0.333;MQ=25.89;MQ0=0;MQRankSum=-0.063;QD=8.87;ReadPosRankSum=0.952;VQSLOD=-3.333;culprit=MQ GT:AD:DP:FT:GQ:PL 0/1:10,5:15:dp:99:99,0,2147483647 0/1:2,5:7:dp;rd:34:128,0,34 0/0:26,0:26:PASS:78:0,78,783
1 63735 rs201888535 CCTA C . PASS AC=1;AF=0.167;AN=6;BaseQRankSum=1.138;ClippingRankSum=0.448;DB;DP=176;FS=13.597;MLEAC=1;MLEAF=0.167;MQ=31.06;MQ0=0;MQRankSum=0.636;QD=9.98;ReadPosRankSum=-1.18 GT:AD:DP:FT:GQ:PL 0/0:27,0:27:PASS:79:0,79,1425 0/0:40,0:40:PASS:99:0,117,2120 0/1:23,74:97:rd:99:3034,0,942
2 19190 . GC G . PASS AC=3;AF=0.5;AN=6;BaseQRankSum=4.157;ClippingRankSum=3.666;DP=74;FS=37.037;MLEAC=3;MLEAF=0.5;MQ=22.26;MQ0=0;MQRankSum=0.195;QD=16.04;ReadPosRankSum=-4.072 GT:AD:DP:FT:GQ:PL 0/1:8,14:22:PASS:99:416,0,2147483647 0/1:18,13:31:PASS:99:353,0,503 0/1:5,15:20:rd:99:457,0,107
13 752721 rs3131972 A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL 1/1:0,27:27:PASS:81:1021,81,0 1/1:0,19:19:dp:57:661,57,0 1/1:0,22:22:PASS:66:831,66,0
13 752791 . A G . PASS AC=6;AF=1.0;AN=6;DB;DP=69;FS=0.0;MLEAC=6;MLEAF=1.0;MQ=60.0;MQ0=0;POSITIVE_TRAIN_SITE;QD=31.67;VQSLOD=18.94;culprit=QD GT:AD:DP:FT:GQ:PL:SB 1/1:0,27:27:PASS:81:1021,81,0:0,1,2,3 1/1:0,19:19:dp:57:661,57,0:4,5,6,7 1/1:0,22:22:PASS:66:831,66,0:2,3,4,5
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,14 @@ class VariantContextConverterSuite extends ADAMFunSuite {
assert(adamGT1.getAlleles.sameElements(List(GenotypeAllele.ALT, GenotypeAllele.OTHER_ALT)))
assert(adamGT1.getAlternateReadDepth === 2)
assert(adamGT1.getGenotypeLikelihoods
.map(f => f: scala.Float)
.map(_.toDouble)
.map(d => d: scala.Double)
.map(PhredUtils.logProbabilityToPhred)
.sameElements(List(59, 0, Int.MaxValue)))

assert(adamGT2.getAlleles.sameElements(List(GenotypeAllele.OTHER_ALT, GenotypeAllele.ALT)))
assert(adamGT2.getAlternateReadDepth === 3)
assert(adamGT2.getGenotypeLikelihoods
.map(f => f: scala.Float)
.map(_.toDouble)
.map(d => d: scala.Double)
.map(PhredUtils.logProbabilityToPhred)
.sameElements(List(59, 1, 102)))

Expand Down Expand Up @@ -392,8 +390,7 @@ class VariantContextConverterSuite extends ADAMFunSuite {
assert(adamGT.getMinReadDepth === 38)
assert(adamGT.getGenotypeLikelihoods.isEmpty)
assert(adamGT.getNonReferenceLikelihoods
.map(f => f: scala.Float)
.map(_.toDouble)
.map(d => d: scala.Double)
.map(PhredUtils.logProbabilityToPhred)
.sameElements(List(0, 1, 2)))
}
Expand Down Expand Up @@ -925,8 +922,8 @@ class VariantContextConverterSuite extends ADAMFunSuite {

test("extract genotype likelihoods going adam->htsjdk") {
val g = converter.extractGenotypeLikelihoods(Genotype.newBuilder
.setGenotypeLikelihoods(Seq(-0.1f, -0.001f, -0.000001f)
.map(f => f: java.lang.Float))
.setGenotypeLikelihoods(Seq(-0.1, -0.001, -0.000001)
.map(d => d: java.lang.Double))
.build, newGb)
.make

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<hadoop.version>2.7.3</hadoop.version>
<hadoop-bam.version>7.8.0</hadoop-bam.version>
<slf4j.version>1.7.22</slf4j.version>
<bdg-formats.version>0.11.0</bdg-formats.version>
<bdg-formats.version>0.11.1-SNAPSHOT</bdg-formats.version>
<bdg-utils.version>0.2.13</bdg-utils.version>
<htsjdk.version>2.9.1</htsjdk.version>
<scoverage.plugin.version>1.1.1</scoverage.plugin.version>
Expand Down

0 comments on commit 8cf09f6

Please sign in to comment.