#!/usr/bin/env python """ bl_stringtie.py - Given a series of Bam files, run stringtie and create GTF files that include FPKM values for genes annotated in the specified GTF file for the genome Synopsis: bl_stringtie.py tsvfile threads [stringtie options] For each Bam file in tsvfile, create a name for the GTF output file. The name of the output file is the longest leading string in common between the two filenames, followed by the .gtf extension. Thus, control1_R.bam control2_R.bam control3_R.bam would output to control1_R.gtf control2_R.gtf control3_R.gtf tsvfile - a tab-separated value file with filenames on separate lines. The first column is assumed to be file names. All other columns are ignored. MUST be the first argument. All stringtie arguments follow. [stringtie options] - options to be passed to stringtie @modified: May 13, 2018 @author: Brian Fristensky @contact: Brian.Fristensky@umanitoba.ca """ import os import subprocess import sys PROGRAM = "bl_stringtie.py : " USAGE = "\n\tUSAGE: bl_stringtie.py tsvfile threads [stringtie options] " DEBUG = True if DEBUG : print('bl_stringtie: Debugging mode on') # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - class Parameters: """ Wrapper class for command line parameters """ def __init__(self): """ Initializes arguments: TSVFILE = "" THREADS = "2" stringtieargs = [] Then calls read_args() to fill in their values from command line """ self.TSVFILE = "" self.THREADS = "2" self.stringtieargs = [] self.read_args() if DEBUG : print('------------ Parameters from command line ------') print(' TSVFILE: ' + self.TSVFILE) print(' THREADS: ' + str(self.THREADS)) print(' stringtieargs: ' + str(self.stringtieargs)) print() def read_args(self): """ Read command line arguments into a Parameter object """ self.TSVFILE = sys.argv[1] self.THREADS = sys.argv[2] self.stringtieargs = sys.argv[3:] #======================== MAIN PROCEDURE ========================== def main(): """ Called when not in documentation mode. """ print('Running ' + PROGRAM) if __name__ == "__main__": main() #else: #used to generate documentation # import doctest # doctest.testmod() #if (BM.documentor() or "-test" in sys.argv): # pass #else: # main()