@@ -17,9 +17,9 @@ from stepRNA.output import make_csv, make_type_csv, write_to_bam, print_hist, re
1717#Scripts to be used...
1818import stepRNA .remove_exact as remove_exact
1919import stepRNA .make_unique as make_unique
20- import stepRNA .run_bowtie as run_bowtie
20+ import stepRNA .stepRNA - run_bowtie as run_bowtie
2121import stepRNA .index_bowtie as index_bowtie
22- import stepRNA .cigar_process as cigar_process
22+ import stepRNA .stepRNA - cigar_process as cigar_process
2323
2424#Modules that need to be installed
2525try :
@@ -60,6 +60,7 @@ optional.add_argument('-m', '--min_score', default=-1, type=int, help='Minimum s
6060flags .add_argument ('-e' , '--remove_exact' , action = 'store_true' , help = 'Remove exact read matches to the reference sequence' )
6161flags .add_argument ('-u' , '--make_unique' , action = 'store_true' , help = 'Make FASTA headers unique in reference and reads i.e. >Read_1 >Read_2' )
6262flags .add_argument ('-j' , '--write_json' , action = 'store_true' , help = 'Write count dictionaries to a JSON file' )
63+ flags .add_argument ('-V' , '--version' , action = 'version' , version = 'stepRNA v1.0.0' , help = 'Print version number then exit.' )
6364
6465#parser._action_groups.append(optional)
6566#parser._action_groups.append(flags)
@@ -109,13 +110,23 @@ sorted_bam = run_bowtie.main(ref_base, reads, prefix, min_score, logger)
109110logger .write ('Alignment completed' )
110111
111112#Cigar process...
113+ fpath = os .path .join (outdir , prefix + '_AlignmentFiles' )
114+ if os .path .isdir (fpath ):
115+ logger .write ('Removing contents in {}' .format (fpath ))
116+ for f in os .listdir (fpath ):
117+ try :
118+ os .remove (os .path .join (fpath , f ))
119+ except :
120+ logger .log ('Could not remove {}' .format (f ))
121+
122+ logger .write ('Processing Cigar strings...' )
112123right_dic , left_dic , type_dic , read_len_dic , refs_read_dic = cigar_process .main (sorted_bam , prefix , args .write_json )
113124logger .write ('Cigar strings processed' )
114125
115126# Count unique references
116127right_unique_dic = defaultdict (lambda :0 )
117128left_unique_dic = defaultdict (lambda :0 )
118- fpath = os .path .join (outdir , 'AlignmentFiles ' )
129+ fpath = os .path .join (outdir , prefix + '_AlignmentFiles ' )
119130for f in os .listdir (fpath ):
120131 if 'passed' not in f :
121132 key = int (f .split ('_' )[- 2 ])
@@ -129,14 +140,14 @@ for f in os.listdir(fpath):
129140
130141#Put overhangs infomation into a csv and print to terminal...
131142logger .write ('\n ## Overhang counts ##' )
132- make_csv ([right_dic , left_dic ], prefix + '_overhang.csv' , ['OH ' ,'Left ' ,'Right ' ])
143+ make_csv ([right_dic , left_dic ], prefix + '_overhang.csv' , ['Overhang ' ,'5prime ' ,'3prime ' ])
133144logger .write ('\n ## Unique overhang counts ##' )
134- make_csv ([right_unique_dic , left_unique_dic ], prefix + '_unique_overhang.csv' , ['OH ' ,'Left ' ,'Right ' ])
145+ make_csv ([right_unique_dic , left_unique_dic ], prefix + '_unique_overhang.csv' , ['Overhang ' ,'3prime ' ,'5prime ' ])
135146logger .write ('\n ## Overhang types ##' )
136- make_type_csv (type_dic , prefix + '_type .csv' , ['OH_type ' , 'count' ])
147+ make_type_csv (type_dic , prefix + '_overhang_type .csv' , ['Classification ' , 'count' ])
137148logger .write ('\n ## Read lengths ##' )
138- make_type_csv (read_len_dic , prefix + '_read_len .csv' , ['Read_length ' , 'count ' ], sort = True )
139- make_type_csv (refs_read_dic , prefix + '_ref_hits .csv' , ['Reference ' , 'count ' ], show = False )
149+ make_type_csv (read_len_dic , prefix + '_passenger_length .csv' , ['sRNA_read ' , 'passenger_count ' ], sort = True )
150+ make_type_csv (refs_read_dic , prefix + '_passenger_number .csv' , ['Passenger_length ' , 'number ' ], show = False )
140151print ()
141152
142153def make_hist (csv_in ):
0 commit comments