diff --git a/lib/Misc.groovy b/lib/Misc.groovy index 05f11db..b992d2b 100644 --- a/lib/Misc.groovy +++ b/lib/Misc.groovy @@ -10,8 +10,7 @@ /* * Function for running fastQC on input samples - */ - + */ static def samtoolSort(bamfile, sortedfile, cpus="1", debug="no") { """ @@ -21,6 +20,24 @@ fi """ } + + /* + * Function for running fastQC on input samples + */ + static def getTranscriptsFromGTF(genome_file, annotation, output="transcript.fa", debug="no") { + + """ + if [ `echo ${debug} == "debug"` ]; then print="echo "; else print=""; fi + if [ `echo ${genome_file} | grep ".gz"` ]; then + \$print zcat ${genome_file} > `basename ${genome_file} .gz` + \$print gffread -g `basename ${genome_file} .gz` -w ${output} ${annotation} + \$print rm `basename ${genome_file} .gz` + else \$print gffread -g ${genome_file} -w ${output} ${annotation} + fi + """ + } + + diff --git a/lib/NGSaligner.groovy b/lib/NGSaligner.groovy index 823d525..d61864e 100644 --- a/lib/NGSaligner.groovy +++ b/lib/NGSaligner.groovy @@ -24,6 +24,38 @@ fi """ } + + /* + * Indexing a transcriptome with Salmon mapper. It reads both gzipped and plain fasta + */ + + static def indexWithSalmon( transcript_file, indexname="transcript.index", kmer, cpus, extrapars="", debug="no") { + + """ + if [ `echo ${transcript_file} | grep ".gz"` ]; then + zcat ${transcript_file} > `basename ${transcript_file} .gz`; + salmon index -t `basename ${transcript_file} .gz` -i ${indexname} --type quasi -k ${kmer} ${extrapars} -p ${cpus}; + rm `basename ${transcript_file} .gz`; + else salmon index -t ${transcript_file} -i ${indexname} --type quasi -k ${kmer} ${extrapars} -p ${cpus} + fi + """ + } + + /* + * Mapping to a transcriptome index with Salmon mapper. + */ + + static def mapPEWithSalmon( transcript_index, readsA, readsB, output, libtype="ISF", cpus, extrapars="", debug="no") { + + """ + + if [ `echo ${readsA} | grep ".gz"` ]; then + salmon quant -i ${transcript_index} --gcBias -l ${libtype} -1 <(gunzip -c ${readsA}) -2 <(gunzip -c ${readsB}) ${extrapars} -o ${output} + else salmon quant -i ${transcript_index} --gcBias -l ${libtype} -1 ${readsA} -2 ${readsB} ${extrapars} -o ${output} + fi + """ + } + /* * Mapping SE and PE reads with Bowtie2. Reads can be both gzipped and plain fastq