@@ -114,18 +114,19 @@ class MAFToGVCF {
114
114
val sampleName = variantsMap.keys.first()
115
115
116
116
// sort the variants by contig and position.
117
- val variants = variantsMap.values.first().sortedWith( VariantContextComparator (contigList))
117
+ val variants = variantsMap.values.first().sortedBy { Position (it.chr,it.startPos) }
118
118
119
- exportVariantContext(sampleName, variants, gvcfOutput, refSeqs)
119
+ exportVariantContext(sampleName, variants, gvcfOutput, refSeqs, outJustGT, delAsSymbolic, maxDeletionSize )
120
120
if (compressAndIndex) {
121
121
// compress and index the file with bgzip and tabix.
122
122
compressAndIndexFile(gvcfOutput)
123
123
}
124
124
} else if (variantsMap.size == 2 ) {
125
125
val outputNames = twoOutputFiles(gvcfOutput)
126
126
variantsMap.entries.forEachIndexed { index, (name, variants) ->
127
- val sortedVariants = variants.sortedWith(VariantContextComparator (contigList))
128
- val outputFile = exportVariantContext(name, sortedVariants, outputNames[index], refSeqs)
127
+ val sortedVariants = variants.sortedBy { Position (it.chr,it.startPos) }
128
+
129
+ val outputFile = exportVariantContext(name, sortedVariants, outputNames[index], refSeqs, outJustGT, delAsSymbolic, maxDeletionSize)
129
130
if (compressAndIndex) {
130
131
compressAndIndexFile(outputNames[index])
131
132
}
@@ -149,7 +150,7 @@ class MAFToGVCF {
149
150
delAsSymbolic : Boolean = false,
150
151
maxDeletionSize : Int = 0,
151
152
anchorwaveLegacy : Boolean = false
152
- ): Map <String , List <VariantContext >> {
153
+ ): Map <String , List <AssemblyVariantInfo >> {
153
154
154
155
val mafRecords = loadMAFRecords(mafFile)
155
156
return if (twoGvcfs) {
@@ -246,7 +247,7 @@ class MAFToGVCF {
246
247
delAsSymbolic : Boolean ,
247
248
maxDeletionSize : Int ,
248
249
anchorwaveLegacy : Boolean = false
249
- ): List <VariantContext > {
250
+ ): List <AssemblyVariantInfo > {
250
251
var variantInfos = mutableListOf<AssemblyVariantInfo >()
251
252
252
253
for (record in mafRecords) {
@@ -263,7 +264,7 @@ class MAFToGVCF {
263
264
variantInfos = fillInMissingVariantBlocks(variantInfos, refGenomeSequence, true )
264
265
}
265
266
266
- return createVariantContextsFromInfo(sampleName, variantInfos, outJustGT, delAsSymbolic, maxDeletionSize)
267
+ return variantInfos
267
268
}
268
269
269
270
fun removeRefBlocks (variantInfos : MutableList <AssemblyVariantInfo >) : MutableList <AssemblyVariantInfo > {
@@ -1117,9 +1118,12 @@ class MAFToGVCF {
1117
1118
*/
1118
1119
fun exportVariantContext (
1119
1120
sampleName : String ,
1120
- variantContexts : List <VariantContext >,
1121
+ variantContexts : List <AssemblyVariantInfo >,
1121
1122
outputFileName : String ,
1122
- refGenomeSequence : Map <String , NucSeq >
1123
+ refGenomeSequence : Map <String , NucSeq >,
1124
+ outputJustGT : Boolean ,
1125
+ delAsSymbolic : Boolean ,
1126
+ maxDeletionSize : Int
1123
1127
) {
1124
1128
val writer = VariantContextWriterBuilder ()
1125
1129
.unsetOption(Options .INDEX_ON_THE_FLY )
@@ -1132,7 +1136,7 @@ class MAFToGVCF {
1132
1136
addSequenceDictionary(header, refGenomeSequence)
1133
1137
writer.writeHeader(header)
1134
1138
for (variant in variantContexts) {
1135
- writer.add(variant)
1139
+ writer.add(convertVariantInfoToContext(sampleName, variant, outputJustGT, delAsSymbolic, maxDeletionSize) )
1136
1140
}
1137
1141
1138
1142
writer.close()
0 commit comments