Commit 2418d783 authored by Holger Brandl's avatar Holger Brandl

allow to override custom star params with environment variable

parent 7c330dc3
......@@ -18,6 +18,7 @@ import kotlin.system.exitProcess
//val args = listOf("/projects/bioinfo/igenomes/Drosophila_melanogaster/Ensembl/BDGP6", "test.fastq.gz")
//val args = listOf("--disable-pe-pairing", "/projects/bioinfo/igenomes/Drosophila_melanogaster/Ensembl/BDGP6", "test.fastq.gz")
//val args = listOf("--star-params", "", "/projects/bioinfo/igenomes/Drosophila_melanogaster/Ensembl/BDGP6", "test.fastq.gz")
// basic usage tutorial
......@@ -34,6 +35,7 @@ Options:
--disable-pe-pairing Disable auto-detection and pairing of paired end tracks
"""
//--star-params <extras> Extra parameters passed on to STAR
val doArgs = Docopt(usage).parse(args.toList()).map {
it.key.removePrefix("--").replace("[<>]".toRegex(), "") to it.value?.toString()
......@@ -50,6 +52,14 @@ val star_index = File(igenome, "Sequence/StarIndex")
val gtfFile = if (doArgs["gtfFile"] != null) File(doArgs["gtfFile"]) else File(igenome, "Annotation/Genes/genes.gtf")
val pePairingEnabled = !doArgs["disable-pe-pairing"]!!.toBoolean()
// does not work because of https://github.com/holgerbrandl/kscript/issues/98
//val extraStarParams = doArgs["star-params"] ?:
// "--outSAMstrandField intronMotif --outFilterIntronMotifs RemoveNoncanonicalUnannotated --outFilterType BySJout --outFilterMultimapNmax 1 --outSJfilterCountUniqueMin 8 3 3 3"
val extraStarParams = System.getenv("STAR_PARAMS").takeIf { it!=null } ?:
"--outSAMstrandField intronMotif --outFilterIntronMotifs RemoveNoncanonicalUnannotated --outFilterType BySJout --outFilterMultimapNmax 1 --outSJfilterCountUniqueMin 8 3 3 3"
println("validating system requirements...")
// make sure that STAR is in the PATH
......@@ -95,12 +105,12 @@ fun detectReverseReads(fastqFile: File): File? {
if (!fastqFile.name.contains("_R1.fastq")) return null
val revReadsCandidate = fastqFile
.absoluteFile
.parentFile
.resolve(fastqFile.name.replace("_R1.fastq", "_R2.fastq"))
.absoluteFile
.parentFile
.resolve(fastqFile.name.replace("_R1.fastq", "_R2.fastq"))
// return revReadsCandidate.takeIf { it.exists() }
return if(revReadsCandidate.exists())revReadsCandidate else null
return if (revReadsCandidate.exists()) revReadsCandidate else null
}
......@@ -130,7 +140,7 @@ for (fastqFile in fastqFiles) {
val cmd = """
STAR --genomeDir ${star_index} --readFilesIn ${fastqFile} ${revReads} --runThreadN 6 ${optionalZcat} --outFileNamePrefix ${fastqBaseName}. --outSAMtype BAM SortedByCoordinate --outSAMstrandField intronMotif --sjdbGTFfile ${gtfFile} --outFilterIntronMotifs RemoveNoncanonicalUnannotated --outFilterType BySJout --quantMode GeneCounts --outFilterMultimapNmax 1 --outSJfilterCountUniqueMin 8 3 3 3
STAR --genomeDir ${star_index} --readFilesIn ${fastqFile} ${revReads} --runThreadN 6 ${optionalZcat} --outFileNamePrefix ${fastqBaseName}. --outSAMtype BAM SortedByCoordinate --sjdbGTFfile ${gtfFile} --quantMode GeneCounts ${extraStarParams}
sleep 5 # to avoid filsystem issues on network volumnes
mv ${fastqBaseName}.Aligned.sortedByCoord.out.bam ${fastqBaseName}.bam
......@@ -151,7 +161,7 @@ jl.waitUntilDone(1000)
// http://lampwww.epfl.ch/~michelou/scala/using-scala-from-java.html
jl.createHtmlReport()
if(!jl.isComplete){
if (!jl.isComplete) {
mailme("star_align.kts failed in ${File(".").absolutePath}", jl.status().toString())
exitProcess(1)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment