Skip to content

Commit

Permalink
Added minimum ion score feature
Browse files Browse the repository at this point in the history
  • Loading branch information
naderm committed Jan 29, 2019
1 parent c25b1fc commit b668879
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions pycamv/fragment/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def validate_spectra(
raw_paths=None,
scans_path=None,
scan_list=None,
score=None,
mat_sessions=None,
out_path=None,
cpu_count=None,
Expand All @@ -302,6 +303,7 @@ def validate_spectra(
raw_paths : list of str
scans_path : str, optional
scan_list : list of int, optional
score : int, optional
mat_sessions : list of str, optional
out_path : str, optional
cpu_count : int, optional
Expand Down Expand Up @@ -332,6 +334,7 @@ def validate_spectra(
fixed_mods, var_mods, pep_queries = search.read_search_file(
search_path,
scan_list=scan_list,
score=score,
)

LOGGER.info("Found info for {} peptide queries".format(len(pep_queries)))
Expand Down
6 changes: 6 additions & 0 deletions pycamv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def _parse_args(args):
nargs="*", type=int,
help="Individual scans to select for validation.",
)
parser.add_argument(
"--score",
type=int,
help="Minimum Ion Score to include for validation.",
)
parser.add_argument(
"--mat-sessions",
nargs="+",
Expand Down Expand Up @@ -189,6 +194,7 @@ def main(args):
raw_paths=args.raw_paths,
scans_path=args.scans_path,
scan_list=args.scans,
score=args.score,
mat_sessions=args.mat_sessions,
out_path=args.out_path,
reprocess=args.reprocess,
Expand Down
13 changes: 12 additions & 1 deletion pycamv/search/discoverer.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ def _get_peptide_queries(
var_mods,
pd_version,
scan_list=None,
score=None,
):
out = []
# index = 0
Expand Down Expand Up @@ -574,6 +575,9 @@ def _get_peptide_queries(
if scan_list and scan not in scan_list:
continue

if score and pep_score < score:
continue

if exp_z < 1:
LOGGER.warning(
"Charge: {}, {} for {} (Scan {})"
Expand Down Expand Up @@ -774,14 +778,16 @@ def _get_pd_version(conn):
return tuple([int(i) for i in next(query)[0].split('.')])


def read_discoverer_msf(msf_path, scan_list=None):
def read_discoverer_msf(msf_path, scan_list=None, score=None):
"""
Parse a ProteomeDiscoverer MSF file.
Parameters
----------
msf_path : str
Path to MSF file.
scan_list : list of int, optional
score : int, optional
Returns
-------
Expand All @@ -794,6 +800,10 @@ def read_discoverer_msf(msf_path, scan_list=None):
os.path.basename(msf_path),
)
)

if score:
LOGGER.info("Using minimum ion score >= {}".format(score))

start = datetime.now()

with sqlite3.connect(msf_path) as conn:
Expand All @@ -808,6 +818,7 @@ def read_discoverer_msf(msf_path, scan_list=None):
var_mods,
pd_version=pd_version,
scan_list=scan_list,
score=score,
)

LOGGER.info(
Expand Down
6 changes: 4 additions & 2 deletions pycamv/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
}


def read_search_file(path, scan_list=None):
def read_search_file(path, scan_list=None, score=None):
"""
Parse a search input file.
Parameters
----------
path : str
Path to search input file.
scan_list : list of int, optional
score : int, optional
Returns
-------
Expand All @@ -39,4 +41,4 @@ def read_search_file(path, scan_list=None):

LOGGER.debug("Using {} backend for {}".format(backend.__name__, ext))

return backend(path, scan_list=scan_list)
return backend(path, scan_list=scan_list, score=score)

0 comments on commit b668879

Please sign in to comment.