Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
logger fix on console , mbr folder in the --output_folder when specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Maux82 committed Jan 20, 2017
1 parent a549742 commit ce26b6e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
21 changes: 9 additions & 12 deletions moff.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


"""
input
- MS2 ID file
Expand Down Expand Up @@ -87,7 +88,7 @@ def pyMZML_xic_out(name, ppmPrecision, minRT, maxRT, MZValue):
return (pd.DataFrame(timeDependentIntensities, columns=['rt', 'intensity']), -1)


def run_apex(file_name, raw_name, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_output):
def run_apex(file_name, raw_name, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_output,log):
# OS detect
flag_windows = False
if _platform in ["linux", "linux2", 'darwin']:
Expand All @@ -113,9 +114,6 @@ def run_apex(file_name, raw_name, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_outp
# extract the name of the file
name = name[0:start]

ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
log.addHandler(ch)

if loc_output != '':
if not (os.path.isdir(loc_output)):
Expand Down Expand Up @@ -158,6 +156,7 @@ def run_apex(file_name, raw_name, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_outp

# read data from file
data_ms2 = pd.read_csv(file_name, sep="\t", header=0)

if not 'matched' in data_ms2.columns:
# check if it is a PS file ,
list_name = data_ms2.columns.values.tolist()
Expand Down Expand Up @@ -221,8 +220,6 @@ def run_apex(file_name, raw_name, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_outp
log.warning('rt not found. Wrong matched peptide in the mbr step line: %i', c)
c += 1
continue

# convert rt to sec to min
try:
if flag_mzml:
# mzml raw file
Expand Down Expand Up @@ -378,11 +375,11 @@ def run_apex(file_name, raw_name, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_outp
h_rt_w = args.rt_window
s_w = args.rt_p_window
s_w_match = args.rt_p_window_match
# if args.raw_list is not None:
# raw_list = args.raw_list
# else:
# raw_list = None

loc_raw = args.raw
loc_output = args.loc_out
# " init here the logger
run_apex(file_name, args.raw_list, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_output)
# set stream option for logger
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
log.addHandler(ch)
run_apex(file_name, args.raw_list, tol, h_rt_w, s_w, s_w_match, loc_raw, loc_output,log)
11 changes: 5 additions & 6 deletions moff_all.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python

import glob
import argparse
import logging
import os
import moff_mbr

import moff
import moff_mbr

import logging
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)

Expand Down Expand Up @@ -100,8 +100,7 @@

log.critical('Apex module ')
c=0
for file_name in mbr_list_loc:
# glob.glob(folder + os.sep + "*.txt"):
for file_name in mbr_list_loc:
tol = args.toll
h_rt_w = args.rt_window
s_w = args.rt_p_window
Expand All @@ -113,5 +112,5 @@
raw_list = None
loc_raw = args.raw
loc_output = args.loc_out
moff.run_apex(file_name,raw_list ,tol, h_rt_w, s_w, s_w_match, loc_raw, loc_output)
moff.run_apex(file_name,raw_list ,tol, h_rt_w, s_w, s_w_match, loc_raw, loc_output,log)
c+=1
20 changes: 12 additions & 8 deletions moff_mbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,22 @@ def run_mbr(args):
log.addHandler(ch)

if args.loc_in is None:
# output mbr_folder will be in the specified folder
output_dir = os.path.join('mbr_output')
#print output_dir
## the user uses --inputtsv option
if not (args.loc_out is None):
# if the user use --output_folder the mbr folder will be created there
output_dir = os.path.join(args.loc_out,'mbr_output')
else:
# if the user does not use --output_folder the mbr folder will be created on moFF path location
output_dir = os.path.join('mbr_output')
print os.path.abspath(output_dir)

else:
## the user use the --inputF option
if os.path.exists(os.path.join(args.loc_in)):
# if '/' in str(args.loc_in):
output_dir = os.path.join(args.loc_in, 'mbr_output')
else:
exit(os.path.join(args.loc_in) + ' EXIT input folder path not well specified --> / missing ')

exit(os.path.join(args.loc_in) + ' EXIT input folder path is not well specified --> / missing or wrong path')

# if not (os.path.isdir(args.loc_in)):
# exit(str(args.loc_in) + '--> input folder does not exist ! ')
Expand All @@ -137,11 +142,10 @@ def run_mbr(args):
# exit(os.path.join(args.loc_in) + ' EXIT input folder path not well specified --> / missing ')

if not (os.path.isdir(output_dir)):
log.critical("Created MBR output folder in : %s ", output_dir)
log.critical("Created MBR output folder in : %s ", os.path.abspath(output_dir))
os.makedirs(output_dir)
else:
log.critical("MBR Output folder in : %s ", output_dir)
# log.setLevel(logging.DEBUG)
log.critical("MBR Output folder in : %s ", os.path.abspath(output_dir))
# set log to file
w_mbr = logging.FileHandler(os.path.join(output_dir, args.log_label + '_mbr_.log'), mode='w')
w_mbr.setLevel(logging.INFO)
Expand Down

0 comments on commit ce26b6e

Please sign in to comment.