Skip to content

Commit

Permalink
added --input-fasta-file argument
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandr committed Dec 2, 2016
1 parent c0944ee commit 3e2c292
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
34 changes: 27 additions & 7 deletions mhctools/cli/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
import pkg_resources
import sys

from .args import make_mhc_arg_parser, mhc_binding_predictor_from_args
from pyensembl.fasta import parse_fasta_dictionary

from .args import make_mhc_arg_parser, mhc_binding_predictor_from_args

logging.config.fileConfig(pkg_resources.resource_filename(__name__, 'logging.conf'))
logger = logging.getLogger(__name__)
Expand All @@ -31,7 +32,15 @@

def add_input_args(arg_parser):
input_group = arg_parser.add_argument_group("Inputs")
input_group.add_argument("--sequence", nargs="*")
input_group.add_argument(
"--sequence",
nargs="*",
help=(
"Protein sequences from which MHC binding predictor will extract "
"potentially shorter peptides."))
input_group.add_argument(
"--input-fasta-file",
help="Path to FASTA file which contains protein sequences")
return input_group

def add_output_args(parser):
Expand All @@ -58,11 +67,22 @@ def main(args_list=None):
args_list = sys.argv[1:]
args = arg_parser.parse_args(args_list)
predictor = mhc_binding_predictor_from_args(args)
input_dictionary = {
("sequence%d" % i): seq
for (i, seq)
in enumerate(args.sequence)
}
if args.sequence:
input_dictionary = {
("input-sequence-%d" % i): seq
for (i, seq)
in enumerate(args.sequence)
}
else:
input_dictionary = {}

if args.input_fasta_file:
input_dictionary.update(parse_fasta_dictionary(args.input_fasta_file))

if len(input_dictionary) == 0:
raise ValueError(
("No input sequences provided, "
"use either --sequence or --input-fasta-file"))
epitope_collection = predictor.predict(input_dictionary)
df = epitope_collection.to_dataframe()
logger.info('\n%s', df)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
numpy>=1.7
pandas>=0.13.1
pyensembl>=1.0.3
varcode>=0.5.9
six>=1.9.0
pylint>=1.4.4
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2014. Mount Sinai School of Medicine
# Copyright (c) 2014-2016. Mount Sinai School of Medicine
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -66,6 +66,7 @@
'numpy>=1.7',
'pandas>=0.13.1',
'varcode>=0.5.9',
'pyensembl>=1.0.3',
'six>=1.9.0',
'sercol>=0.0.2',
'mhcnames',
Expand Down
2 changes: 1 addition & 1 deletion test/test_parsing_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from nose.tools import eq_
from mhctools.cli.parsing_helpers import parse_int_list
from mhctools.cli.parsing_helpers import parse_int_list, parse_fasta_string

def test_parse_int_list():
# int by itself
Expand Down

0 comments on commit 3e2c292

Please sign in to comment.