Skip to content
Snippets Groups Projects
Commit da908cbb authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Changed to SamReaderFactory

parent ef085f81
Branches
Tags
No related merge requests found
...@@ -3,7 +3,7 @@ package nl.lumc.sasc.biopet.pipelines.gatk ...@@ -3,7 +3,7 @@ package nl.lumc.sasc.biopet.pipelines.gatk
import nl.lumc.sasc.biopet.core.MultiSampleQScript import nl.lumc.sasc.biopet.core.MultiSampleQScript
import nl.lumc.sasc.biopet.core.PipelineCommand import nl.lumc.sasc.biopet.core.PipelineCommand
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
import htsjdk.samtools.SAMFileReader import htsjdk.samtools.SamReaderFactory
import scala.collection.JavaConversions._ import scala.collection.JavaConversions._
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.extensions.gatk.{ CombineVariants, CombineGVCFs } import nl.lumc.sasc.biopet.extensions.gatk.{ CombineVariants, CombineGVCFs }
...@@ -185,7 +185,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri ...@@ -185,7 +185,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
libraryOutput.mappedBamFile = mapping.outputFiles("finalBamFile") libraryOutput.mappedBamFile = mapping.outputFiles("finalBamFile")
} else { } else {
var readGroupOke = true var readGroupOke = true
val inputSam = new SAMFileReader(bamFile) val inputSam = SamReaderFactory.makeDefault.open(bamFile)
val header = inputSam.getFileHeader.getReadGroups val header = inputSam.getFileHeader.getReadGroups
for (readGroup <- inputSam.getFileHeader.getReadGroups) { for (readGroup <- inputSam.getFileHeader.getReadGroups) {
if (readGroup.getSample != sampleID) logger.warn("Sample ID readgroup in bam file is not the same") if (readGroup.getSample != sampleID) logger.warn("Sample ID readgroup in bam file is not the same")
......
package nl.lumc.sasc.biopet.tools package nl.lumc.sasc.biopet.tools
import htsjdk.samtools.SAMFileReader import htsjdk.samtools.{ SAMSequenceRecord, SamReaderFactory }
import htsjdk.samtools.SAMSequenceRecord
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.ToolCommand import nl.lumc.sasc.biopet.core.ToolCommand
...@@ -68,7 +67,7 @@ object BedToInterval extends ToolCommand { ...@@ -68,7 +67,7 @@ object BedToInterval extends ToolCommand {
val writer = new PrintWriter(commandArgs.outputFile) val writer = new PrintWriter(commandArgs.outputFile)
val inputSam = new SAMFileReader(commandArgs.bamFile) val inputSam = SamReaderFactory.makeDefault.open(commandArgs.bamFile)
val refs = for (SQ <- inputSam.getFileHeader.getSequenceDictionary.getSequences.toArray) yield { val refs = for (SQ <- inputSam.getFileHeader.getSequenceDictionary.getSequences.toArray) yield {
val record = SQ.asInstanceOf[SAMSequenceRecord] val record = SQ.asInstanceOf[SAMSequenceRecord]
writer.write("@SQ\tSN:" + record.getSequenceName + "\tLN:" + record.getSequenceLength + "\n") writer.write("@SQ\tSN:" + record.getSequenceName + "\tLN:" + record.getSequenceLength + "\n")
......
package nl.lumc.sasc.biopet.tools package nl.lumc.sasc.biopet.tools
import htsjdk.samtools.SAMFileReader import htsjdk.samtools.{ SAMRecord, SamReaderFactory }
import htsjdk.samtools.SAMRecord
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction import nl.lumc.sasc.biopet.core.BiopetJavaCommandLineFunction
import nl.lumc.sasc.biopet.core.ToolCommand import nl.lumc.sasc.biopet.core.ToolCommand
...@@ -57,7 +56,7 @@ object BiopetFlagstat extends ToolCommand { ...@@ -57,7 +56,7 @@ object BiopetFlagstat extends ToolCommand {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1)
val inputSam = new SAMFileReader(commandArgs.inputFile) val inputSam = SamReaderFactory.makeDefault.open(commandArgs.inputFile)
val iterSam = if (commandArgs.region == None) inputSam.iterator else { val iterSam = if (commandArgs.region == None) inputSam.iterator else {
val regionRegex = """(.*):(.*)-(.*)""".r val regionRegex = """(.*):(.*)-(.*)""".r
commandArgs.region.get match { commandArgs.region.get match {
......
package nl.lumc.sasc.biopet.tools package nl.lumc.sasc.biopet.tools
import htsjdk.samtools.SAMFileReader import htsjdk.samtools.{ QueryInterval, SamReaderFactory, SAMRecord, SamReader }
import htsjdk.samtools.QueryInterval
import htsjdk.samtools.SAMRecord
import htsjdk.variant.variantcontext.VariantContext import htsjdk.variant.variantcontext.VariantContext
import htsjdk.variant.variantcontext.VariantContextBuilder import htsjdk.variant.variantcontext.VariantContextBuilder
import htsjdk.variant.variantcontext.writer.AsyncVariantContextWriter import htsjdk.variant.variantcontext.writer.AsyncVariantContextWriter
...@@ -69,7 +67,8 @@ object CheckAllelesVcfInBam extends ToolCommand { ...@@ -69,7 +67,8 @@ object CheckAllelesVcfInBam extends ToolCommand {
if (commandArgs.bamFiles.size != commandArgs.samples.size) if (commandArgs.bamFiles.size != commandArgs.samples.size)
logger.warn("Number of samples is diffrent then number of bam files, left over will be removed") logger.warn("Number of samples is diffrent then number of bam files, left over will be removed")
val bamReaders: Map[String, SAMFileReader] = Map(commandArgs.samples zip commandArgs.bamFiles.map(x => new SAMFileReader(x)): _*) val samReaderFactory = SamReaderFactory.makeDefault
val bamReaders: Map[String, SamReader] = Map(commandArgs.samples zip commandArgs.bamFiles.map(x => samReaderFactory.open(x)): _*)
val bamHeaders = bamReaders.map(x => (x._1, x._2.getFileHeader)) val bamHeaders = bamReaders.map(x => (x._1, x._2.getFileHeader))
val reader = new VCFFileReader(commandArgs.inputFile, false) val reader = new VCFFileReader(commandArgs.inputFile, false)
......
/*
* Copyright 2014 pjvan_thof.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.lumc.sasc.biopet.tools package nl.lumc.sasc.biopet.tools
import htsjdk.samtools.QueryInterval import htsjdk.samtools.{ QueryInterval, SAMRecord, SamReaderFactory, ValidationStringency }
import htsjdk.samtools.SAMFileReader
import htsjdk.samtools.ValidationStringency
import htsjdk.samtools.SAMRecord
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.ToolCommand import nl.lumc.sasc.biopet.core.ToolCommand
import scala.io.Source import scala.io.Source
...@@ -44,8 +25,9 @@ object FindRepeatsPacBio extends ToolCommand { ...@@ -44,8 +25,9 @@ object FindRepeatsPacBio extends ToolCommand {
val argsParser = new OptParser val argsParser = new OptParser
val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1) val commandArgs: Args = argsParser.parse(args, Args()) getOrElse sys.exit(1)
val bamReader = new SAMFileReader(commandArgs.inputBam) val bamReader = SamReaderFactory.makeDefault
bamReader.setValidationStringency(ValidationStringency.SILENT) .validationStringency(ValidationStringency.SILENT)
.open(commandArgs.inputBam)
val bamHeader = bamReader.getFileHeader val bamHeader = bamReader.getFileHeader
val header = List("chr", "startPos", "stopPos", "Repeat_seq", "repeatLength", val header = List("chr", "startPos", "stopPos", "Repeat_seq", "repeatLength",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment