Skip to content

Commit

Permalink
Time limit signal (#15)
Browse files Browse the repository at this point in the history
* testing time limits

* futher checks for time

* added signal

* rm unwanted files

* fixed indention bug

* fixes

* close signal

* added more checks for test
  • Loading branch information
Tomnl authored Jun 23, 2020
1 parent 9d58084 commit 3ab8c35
Show file tree
Hide file tree
Showing 4 changed files with 461 additions and 417 deletions.
2 changes: 1 addition & 1 deletion msnpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

__author__ = 'Ralf Weber ([email protected])'
__credits__ = 'Ralf Weber ([email protected])'
__version__ = '1.0.0a5'
__version__ = '1.0.0a6'
__license__ = 'GPLv3'
70 changes: 43 additions & 27 deletions msnpy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def main(): # pragma: no cover
action='store_true', required=False,
help="Filter the spectral tree annotations.")

parser_ast.add_argument('-t', '--time_limit',
default=None, type=float, required=False,
parser_ast.add_argument('-t', '--time-limit',
default=None, type=int, required=False,
help="Time limit (seconds) for each tree to be processed for annotation")

#################################
Expand Down Expand Up @@ -399,32 +399,48 @@ def main(): # pragma: no cover
save_trees(spectral_trees, args.output, format="json")

if args.step == "convert-spectral-trees":

print('converting trees to dimspy peaklists')
if args.input_type=='json':
non_merged_pls, merged_pls, ms1_precursor_pl = tree2peaklist(tree_pth=args.input,
out_pth=args.output,
name=args.name,
adjust_mz=args.adjust_mz,
merge=args.merge,
ppm=args.ppm)
if args.msp:
print('Converting dimspy peaklists to MSP files')
if non_merged_pls:
peaklist2msp(non_merged_pls,
os.path.join(args.output, '{}_non_merged.msp'.format(args.name)),
msp_type=args.msp_type,
polarity=args.polarity)
if merged_pls:
peaklist2msp(merged_pls,
os.path.join(args.output, '{}_merged.msp'.format(args.name)),
msp_type=args.msp_type,
polarity=args.polarity)
if ms1_precursor_pl:
peaklist2msp(ms1_precursor_pl,
os.path.join(args.output, '{}_ms1_precursors.msp'.format(args.name)),
msp_type=args.msp_type,
polarity=args.polarity,
include_ms1=True)
if args.input_type == 'json':

if os.stat(args.input).st_size == 0:
def touch(path):
with open(path, 'a'):
os.utime(path, None)
# Needed to keep Galaxy workflows from failing in Galaxy
touch(os.path.join(args.output, '{}_non_merged_pls.hdf5'.format(args.name)))
touch(os.path.join(args.output, '{}_merged_pls.hdf5'.format(args.name)))
touch(os.path.join(args.output, '{}_ms1_precursors_pl.hdf5'.format(args.name)))
touch(os.path.join(args.output, '{}_non_merged.msp'.format(args.name)))
touch(os.path.join(args.output, '{}_merged.msp'.format(args.name)))
touch(os.path.join(args.output, '{}_ms1_precursors.msp'.format(args.name)))
else:
non_merged_pls, merged_pls, ms1_precursor_pl = tree2peaklist(tree_pth=args.input,
out_pth=args.output,
name=args.name,
adjust_mz=args.adjust_mz,
merge=args.merge,
ppm=args.ppm)

if args.msp:
print('Converting dimspy peaklists to MSP files')
if non_merged_pls:
peaklist2msp(non_merged_pls,
os.path.join(args.output, '{}_non_merged.msp'.format(args.name)),
msp_type=args.msp_type,
polarity=args.polarity)
if merged_pls:
peaklist2msp(merged_pls,
os.path.join(args.output, '{}_merged.msp'.format(args.name)),
msp_type=args.msp_type,
polarity=args.polarity)
if ms1_precursor_pl:
peaklist2msp(ms1_precursor_pl,
os.path.join(args.output, '{}_ms1_precursors.msp'.format(args.name)),
msp_type=args.msp_type,
polarity=args.polarity,
include_ms1=True)

else:
pls = hdf5_portal.load_peaklists_from_hdf5(args.input)
peaklist2msp(pls,
Expand Down
Loading

0 comments on commit 3ab8c35

Please sign in to comment.