Skip to content

Commit

Permalink
fix for checking default config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dmnfarrell committed May 9, 2017
1 parent c7bc046 commit 0f27924
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
32 changes: 18 additions & 14 deletions smallrnaseq/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def setup(self):
else:
self.labels = None
if self.ref_fasta != None:
if not os.path.exists(self.ref_fasta):
print ('WARNING ref fasta %s not found' %self.ref_fasta)
self.ref_name = os.path.splitext(os.path.basename(self.ref_fasta))[0]
else:
self.ref_name = None
Expand Down Expand Up @@ -125,21 +127,23 @@ def map_libraries(self):

out = self.output
libraries = self.libraries
if libraries == '' or len(libraries) == 0:
print ('no libaries to map to')
return

if libraries != '' and len(libraries)>0:
#map to provided libraries
print ('mapping to these libraries: %s' %libraries)
res, counts = base.map_rnas(self.files, libraries, self.temp_path,
aligner=self.aligner,
samplelabels=self.labels,
params=self.aligner_params)
if res is None:
print ('empty data returned. did alignments run?')
return
print ('results saved to rna_counts.csv')
res.to_csv( os.path.join(out, 'rna_found.csv'),index=False)
counts.to_csv( os.path.join(out, 'rna_counts.csv'), index=False )
plot_results(res, out)
#map to provided libraries
print ('mapping to these libraries: %s' %libraries)
res, counts = base.map_rnas(self.files, libraries, self.temp_path,
aligner=self.aligner,
samplelabels=self.labels,
params=self.aligner_params)
if res is None:
print ('empty data returned. did alignments run?')
return
print ('results saved to rna_counts.csv')
res.to_csv( os.path.join(out, 'rna_found.csv'),index=False)
counts.to_csv( os.path.join(out, 'rna_counts.csv'), index=False )
plot_results(res, out)
return

def map_mirnas(self):
Expand Down
4 changes: 2 additions & 2 deletions smallrnaseq/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def map_rnas(files, indexes, outpath, collapse=True, adapters=None, aligner='bow
if len(cfiles)==0:
print ('WARNING no files to align')
return
print (cfiles)
print ('')
result = []
#store current aligner parameters as default
default_params = aligners.get_current_params(aligner)
Expand Down Expand Up @@ -502,7 +502,7 @@ def collapse_files(files, outpath, **kwargs):
if res == False:
continue
else:
print ('found collapsed file')
print ('found collapsed file %s' %collapsedfile)
outfiles.append(collapsedfile)
return outfiles

Expand Down
10 changes: 6 additions & 4 deletions smallrnaseq/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ def check_options(opts):
"""Check for missing default options in dict. Meant to handle
incomplete config files"""

defaults = dict(baseoptions['base'])
for i in defaults:
if i not in opts:
opts[i] = defaults[i]
sections = baseoptions.keys()
for s in sections:
defaults = dict(baseoptions[s])
for i in defaults:
if i not in opts:
opts[i] = defaults[i]
return opts

0 comments on commit 0f27924

Please sign in to comment.