Commit 5f142911 authored by Nicolas  MAILLET's avatar Nicolas MAILLET
Browse files

Modify input -e and -m (replace -e 2 -e 3 by -e 2 3)

parent e4519749
......@@ -16,7 +16,7 @@ You can obtain help by using:
.. code-block:: none
rpg -\\-help
rpg --help
Installation
......@@ -35,7 +35,7 @@ Then you can use:
.. code-block:: none
rpg -\\-help
rpg --help
From source code
----------------
......@@ -113,7 +113,7 @@ To perform sequential digestion of the sequence "QWSDORESDF" with enzymes 2 and
.. code-block:: none
rpg -i QWSDORESDF -o output_file.fasta -e 2 -e 5
rpg -i QWSDORESDF -o output_file.fasta -e 2 5
Sequential digestion of a (multi)fasta file
"""""""""""""""""""""""""""""""""""""""""""
......@@ -122,7 +122,7 @@ To perform sequential digestion of `input_file.fasta` with enzymes 2 and 5 and s
.. code-block:: none
rpg -i input_file.fasta -o output_file.fasta -e 2 -e 5
rpg -i input_file.fasta -o output_file.fasta -e 2 5
Concurrent digestion of a (multi)fasta file
"""""""""""""""""""""""""""""""""""""""""""
......@@ -131,7 +131,7 @@ To perform concurrent digestion of `input_file.fasta` with enzymes 2 and 5 and s
.. code-block:: none
rpg -i input_file.fasta -o output_file.fasta -e 2 -e 5 -d c
rpg -i input_file.fasta -o output_file.fasta -e 2 5 -d c
Adding a new enzyme
-------------------
......@@ -156,7 +156,7 @@ Here are all available options in **RPG**:
**-d, -\\-digest**: Digestion mode. Either 's', 'sequential', 'c' or 'concurrent' (default: s). See :ref:`digestion` for more information.
**-e, -\\-enzymes**: Enzyme(s) id number to use (*i.e.* -e 0 -e 5 -e 10 to use enzymes 0, 5 and 10). Use -l first to get enzyme ids. See :ref:`enzymes` for more information.
**-e, -\\-enzymes**: Enzyme(s) id number to use (*i.e.* -e 0 5 10 to use enzymes 0, 5 and 10). Use -l first to get enzyme ids. See :ref:`enzymes` for more information.
**-f, -\\-fmt**: Output file format. Either 'fasta', 'csv', or 'tsv' (default: fasta). See :ref:`formats` for more information.
......@@ -164,7 +164,7 @@ Here are all available options in **RPG**:
**-l, -\\-list**: Display the list of available enzymes.
**-m, -\\-miscleavage**: Percentage of miscleavage, between 0 and 100, by enzyme(s). It should be in the same order as the -\\-enzymes options (*i.e.* -m 15 -m 5 -m 10). It works only for sequential digestion (default: 0). See :ref:`miscleavage` for more information.
**-m, -\\-miscleavage**: Percentage of miscleavage, between 0 and 100, by enzyme(s). It should be in the same order as the -\\-enzymes options (*i.e.* -m 15 5.2 10). It works only for sequential digestion (default: 0). See :ref:`miscleavage` for more information.
**-n, -\\-noninteractive**: Non-interactive mode. No standard output, only error(s) (-\\-quiet enable, overwrite -v). If output filename already exists, output file will be overwritten. See :ref:`nointer` for more information.
......@@ -192,7 +192,7 @@ Let's define two enzymes. The first is called 'afterP' (id 28) and cleaves after
.. code-block:: none
$ rpg -i PKPKPKPK -e 28 -e 29
$ rpg -i PKPKPKPK -e 28 29
>Input_0_afterP_1_1_115.13198_5.54
P
>Input_1_afterP_3_2_243.30608_9.4
......@@ -212,7 +212,7 @@ Digesting 'PKPKPKPK' using those two enzymes in concurrent mode gives the follow
.. code-block:: none
$ rpg -i PKPKPKPK -e 28 -e 29 -d c
$ rpg -i PKPKPKPK -e 28 29 -d c
>Input_0_afterP-afterK_1_1_115.13198_5.54
P
>Input_1_afterP-afterK_2_1_146.18938_9.4
......@@ -246,7 +246,7 @@ For example, using:
.. code-block:: none
rpg -i QWSDORESDF -e 1 -e 2 -e 3 -m 1.4 -m 2.6
rpg -i QWSDORESDF -e 1 2 3 -m 1.4 2.6
will assign a miscleavage probability of `1.4%` to enzyme `1`, a miscleavage probability of `2.6%` to enzyme `2` and a miscleavage probability of `0%` to enzyme `3` (default behavior). For enzyme `1`, each cleavage will then have a probability of 0.014 to **not** occur.
......
......@@ -39,7 +39,7 @@ import os
import sys
import uuid
from pathlib import Path
#from context import rpg
from context import rpg
from rpg import core
from rpg import digest
from rpg import enzyme
......@@ -177,12 +177,12 @@ def get_enzymes_to_use(mode, id_enz_selected, miscleavage):
# Ask user to give correct enzymes ids
while not enzymes_to_use:
id_enz_inp = input("Choose which enzyme(s) to use, separated by"
" comma (example: 1,5,6). (q) to quit:\n")
" space (example: 1 5 6). (q) to quit:\n")
# Quit
if "q" in id_enz_inp:
sys.exit(0)
# Get a list of ids
for i in id_enz_inp.split(","):
for i in id_enz_inp.split(" "):
try:
# Convert it to int
i = int(i)
......@@ -195,11 +195,11 @@ def get_enzymes_to_use(mode, id_enz_selected, miscleavage):
mc_enz_inputed = []
if mode == "sequential":
mc_enz_inp = input("Percentage of miscleavage per inputed"
" enzyme (default 0), separated by comma"
" (example: 1,5,6):\n")
" enzyme (default 0), separated by sapce"
" (example: 1.2 5 6):\n")
if mc_enz_inp:
# Get a list of int
for i in mc_enz_inp.split(","):
for i in mc_enz_inp.split(" "):
try:
# Convert it to int
i = float(i)
......@@ -252,10 +252,9 @@ def main():
default="s", help="Digestion mode. Either 's', 'seque"
"ntial', 'c' or 'concurrent' (default: s)")
parser.add_argument("-e", "--enzymes", metavar="", default=[],
action='append', type=restricted_enzyme_id,
help="Id of enzyme(s) to use (i.e. -e 0 -e 5 -e 10 to"
" use enzymes 0, 5 and 10). Use -l first to get "
"enzyme ids")
nargs='+', type=restricted_enzyme_id,
help="Id of enzyme(s) to use (i.e. -e 0 5 10 to use "
"enzymes 0, 5 and 10). Use -l first to get enzyme ids")
parser.add_argument("-f", "--fmt", metavar="",
choices=['fasta', 'csv', 'tsv'], default="fasta",
help="Output file format. Either 'fasta', 'csv', or "
......@@ -266,11 +265,11 @@ def main():
group_launch.add_argument("-l", "--list", action="store_true",
help="Display the list of available enzymes")
parser.add_argument("-m", "--miscleavage", metavar="", default=[],
action='append', type=restricted_float,
nargs='+', type=restricted_float,
help="Percentage of miscleavage, between 0 and 100,"
" by enzyme(s). It should be in the same order than "
"-enzymes options (i.e. -m 15 -m 5 -m 10). Only for "
"sequential digestion (default: 0)")
"-enzymes options (i.e. -m 15 5 10). Only for sequenti"
"al digestion (default: 0)")
parser.add_argument("-n", "--noninteractive", action='store_true',
help="Non-interactive mode. No standard output, only "
"error(s) (--quiet enable, overwrite -v). If output "
......
......@@ -85,12 +85,12 @@ def test_output_results(capsys, tmpdir):
assert out == output_file.read()
assert output_file.read() == "Original_header,No_peptide,Enzyme,Cleaving_"\
"pos,Peptide_size,Peptide_mass,pI,Sequence\n"\
"Input,0,fake_enzyme1,4,4,534.52598,3.6,WQSD"\
"\nInput,1,fake_enzyme1,7,3,349.29758,3.4,ES"\
"D\nInput,2,fake_enzyme1,12,5,495.48938,3.6,"\
"Input,0,fake_enzyme1,4,4,534.52598,3.14,WQSD"\
"\nInput,1,fake_enzyme1,7,3,349.29758,3.04,ES"\
"D\nInput,2,fake_enzyme1,12,5,495.48938,3.14,"\
"FZQSD\nInput,3,fake_enzyme1,15,3,349.29758,"\
"3.4,ESD\nInput,4,fake_enzyme1,16,1,165.1918"\
"8,5.54,F\n"
"3.04,ESD\nInput,4,fake_enzyme1,16,1,165.1918"\
"8,5.97,F\n"
# TSV output
output_file = tmpdir.join("test_result.tsv")
......@@ -103,12 +103,12 @@ def test_output_results(capsys, tmpdir):
assert output_file.read() == "Original_header\tNo_peptide\tEnzyme\tCleavi"\
"ng_pos\tPeptide_size\tPeptide_mass\tpI\tSeq"\
"uence\nInput\t0\tfake_enzyme1\t4\t4\t534.52"\
"598\t3.6\tWQSD\nInput\t1\tfake_enzyme1\t7\t"\
"3\t349.29758\t3.4\tESD\nInput\t2\tfake_enzy"\
"me1\t12\t5\t495.48938\t3.6\tFZQSD\nInput\t3"\
"\tfake_enzyme1\t15\t3\t349.29758\t3.4\tESD"\
"598\t3.14\tWQSD\nInput\t1\tfake_enzyme1\t7\t"\
"3\t349.29758\t3.04\tESD\nInput\t2\tfake_enzy"\
"me1\t12\t5\t495.48938\t3.14\tFZQSD\nInput\t3"\
"\tfake_enzyme1\t15\t3\t349.29758\t3.04\tESD"\
"\nInput\t4\tfake_enzyme1\t16\t1\t165.19188"\
"\t5.54\tF\n"
"\t5.97\tF\n"
# Fasta output
output_file = tmpdir.join("test_result.fasta")
......@@ -118,12 +118,12 @@ def test_output_results(capsys, tmpdir):
core.output_results(str(output_file), all_seq_digested, fmt, quiet, verbose)
out, err = capsys.readouterr()
assert out == output_file.read()
assert output_file.read() == ">Input_0_fake_enzyme1_4_4_534.52598_3.6\nWQ"\
"SD\n>Input_1_fake_enzyme1_7_3_349.29758_3.4"\
assert output_file.read() == ">Input_0_fake_enzyme1_4_4_534.52598_3.14\nWQ"\
"SD\n>Input_1_fake_enzyme1_7_3_349.29758_3.04"\
"\nESD\n>Input_2_fake_enzyme1_12_5_495.48938"\
"_3.6\nFZQSD\n>Input_3_fake_enzyme1_15_3_349"\
".29758_3.4\nESD\n>Input_4_fake_enzyme1_16_1"\
"_165.19188_5.54\nF\n"
"_3.14\nFZQSD\n>Input_3_fake_enzyme1_15_3_349"\
".29758_3.04\nESD\n>Input_4_fake_enzyme1_16_1"\
"_165.19188_5.97\nF\n"
# CSV output in quiet
seq = "WQSDESDFZQSDESDF"
......@@ -139,12 +139,12 @@ def test_output_results(capsys, tmpdir):
assert out == ""
assert output_file.read() == "Original_header,No_peptide,Enzyme,Cleaving_"\
"pos,Peptide_size,Peptide_mass,pI,Sequence\n"\
"Input,0,fake_enzyme1,4,4,534.52598,3.6,WQSD"\
"\nInput,1,fake_enzyme1,7,3,349.29758,3.4,ES"\
"D\nInput,2,fake_enzyme1,12,5,495.48938,3.6,"\
"Input,0,fake_enzyme1,4,4,534.52598,3.14,WQSD"\
"\nInput,1,fake_enzyme1,7,3,349.29758,3.04,ES"\
"D\nInput,2,fake_enzyme1,12,5,495.48938,3.14,"\
"FZQSD\nInput,3,fake_enzyme1,15,3,349.29758,"\
"3.4,ESD\nInput,4,fake_enzyme1,16,1,165.1918"\
"8,5.54,F\n"
"3.04,ESD\nInput,4,fake_enzyme1,16,1,165.1918"\
"8,5.97,F\n"
# CSV output in verbose > 2
seq = "WQSDESDFZQSDESDF"
......@@ -158,12 +158,12 @@ def test_output_results(capsys, tmpdir):
out, err = capsys.readouterr()
assert output_file.read() == "Original_header,No_peptide,Enzyme,Cleaving_"\
"pos,Peptide_size,Peptide_mass,pI,Sequence\n"\
"Input,0,fake_enzyme1,4,4,534.52598,3.6,WQSD"\
"\nInput,1,fake_enzyme1,7,3,349.29758,3.4,ES"\
"D\nInput,2,fake_enzyme1,12,5,495.48938,3.6,"\
"Input,0,fake_enzyme1,4,4,534.52598,3.14,WQSD"\
"\nInput,1,fake_enzyme1,7,3,349.29758,3.04,ES"\
"D\nInput,2,fake_enzyme1,12,5,495.48938,3.14,"\
"FZQSD\nInput,3,fake_enzyme1,15,3,349.29758,"\
"3.4,ESD\nInput,4,fake_enzyme1,16,1,165.1918"\
"8,5.54,F\n"
"3.04,ESD\nInput,4,fake_enzyme1,16,1,165.1918"\
"8,5.97,F\n"
# Verbose > 2
assert out == "\nNumber of cleavage: 4\nCleavage position: 4, 7, 12, 15\n"\
"Number of miscleavage: 0\nmiscleavage position: \nmis"\
......@@ -181,7 +181,7 @@ def test_peptide():
print_res = pep0.__repr__()
assert print_res == "Original header: Test\nNo. peptide: 1\nEnzyme: fake_"\
"enzyme\nCleav. pos: 3\nPep. size: 8\nPep. mass: 1012"\
".98488\nPep. pI: 3.29\nSequence: QWSDESDF\n"
".98488\nPep. pI: 2.91\nSequence: QWSDESDF\n"
# Test function '__eq__()'
pep1 = sequence.Peptide(header, seq, enz_name, 1, 3)
......@@ -201,12 +201,12 @@ def test_peptide():
# Test function '__format__()'
format_res = pep0.__format__("csv")
assert format_res == "Test,1,fake_enzyme,3,8,1012.98488,3.29,QWSDESDF"
assert format_res == "Test,1,fake_enzyme,3,8,1012.98488,2.91,QWSDESDF"
format_res = pep2.__format__("tsv")
assert format_res == "Test\t1\tfake_enzyme\t2\t8\t1012.98488\t3.29\tQWSD"\
assert format_res == "Test\t1\tfake_enzyme\t2\t8\t1012.98488\t2.91\tQWSD"\
"ESDF"
format_res = pep3.__format__("fasta")
assert format_res == ">Test_2_fake_enzyme_3_8_1012.98488_3.29\nQWSDESDF"
assert format_res == ">Test_2_fake_enzyme_3_8_1012.98488_2.91\nQWSDESDF"
# Test function 'def get_isoelectric_point():'
assert pep3.get_isoelectric_point() == 3.29
assert pep3.get_isoelectric_point() == 2.91
......@@ -26,10 +26,10 @@ def test_resultonedigestion():
"66\nPeptides: [Original header: Test\nNo. "\
"peptide: 0\nEnzyme: fake_enzyme\nCleav. po"\
"s: 3\nPep. size: 8\nPep. mass: 1012.98488"\
"\nPep. pI: 3.29\nSequence: QWSDESDF\n, Ori"\
"\nPep. pI: 2.91\nSequence: QWSDESDF\n, Ori"\
"ginal header: Test\nNo. peptide: 1\nEnzyme"\
": fake_enzyme\nCleav. pos: 4\nPep. size: 8"\
"\nPep. mass: 1012.98488\nPep. pI: 3.29\nSe"\
"\nPep. mass: 1012.98488\nPep. pI: 2.91\nSe"\
"quence: QWSDESDF\n]\n"
# Test function '__eq__()'
......@@ -53,15 +53,15 @@ def test_resultonedigestion():
# Test function '__format__()'
format_res = res_dig0.__format__("csv")
assert format_res == "Test,0,fake_enzyme,3,8,1012.98488,3.29,QWSDESDF\nTe"\
"st,1,fake_enzyme,4,8,1012.98488,3.29,QWSDESDF\n"
assert format_res == "Test,0,fake_enzyme,3,8,1012.98488,2.91,QWSDESDF\nTe"\
"st,1,fake_enzyme,4,8,1012.98488,2.91,QWSDESDF\n"
format_res = res_dig0.__format__("tsv")
assert format_res == "Test\t0\tfake_enzyme\t3\t8\t1012.98488\t3.29\tQWSDE"\
"SDF\nTest\t1\tfake_enzyme\t4\t8\t1012.98488\t3.29\t"\
assert format_res == "Test\t0\tfake_enzyme\t3\t8\t1012.98488\t2.91\tQWSDE"\
"SDF\nTest\t1\tfake_enzyme\t4\t8\t1012.98488\t2.91\t"\
"QWSDESDF\n"
format_res = res_dig0.__format__("fasta")
assert format_res == ">Test_0_fake_enzyme_3_8_1012.98488_3.29\nQWSDESDF\n"\
">Test_1_fake_enzyme_4_8_1012.98488_3.29\nQWSDESDF\n"
assert format_res == ">Test_0_fake_enzyme_3_8_1012.98488_2.91\nQWSDESDF\n"\
">Test_1_fake_enzyme_4_8_1012.98488_2.91\nQWSDESDF\n"
# Test function 'pop_peptides()'
assert res_dig5.peptides != []
......@@ -350,21 +350,21 @@ def test_digest_from_input(capsys, tmpdir):
"[Original header: Input\nNo. peptide: 0"\
"\nEnzyme: fake_enzyme1\nCleav. pos: 4\nPe"\
"p. size: 4\nPep. mass: 534.52598\nPep. pI"\
": 3.6\nSequence: WQSD\n, Original header:"\
": 3.14\nSequence: WQSD\n, Original header:"\
" Input\nNo. peptide: 1\nEnzyme: fake_enzy"\
"me1\nCleav. pos: 7\nPep. size: 3\nPep. ma"\
"ss: 349.29758\nPep. pI: 3.4\nSequence: ES"\
"ss: 349.29758\nPep. pI: 3.04\nSequence: ES"\
"D\n, Original header: Input\nNo. peptide:"\
" 2\nEnzyme: fake_enzyme1\nCleav. pos: 12"\
"\nPep. size: 5\nPep. mass: 495.48938\nPep"\
". pI: 3.6\nSequence: FZQSD\n, Original he"\
". pI: 3.14\nSequence: FZQSD\n, Original he"\
"ader: Input\nNo. peptide: 3\nEnzyme: fake"\
"_enzyme1\nCleav. pos: 15\nPep. size: 3\nP"\
"ep. mass: 349.29758\nPep. pI: 3.4\nSequen"\
"ep. mass: 349.29758\nPep. pI: 3.04\nSequen"\
"ce: ESD\n, Original header: Input\nNo. pe"\
"ptide: 4\nEnzyme: fake_enzyme1\nCleav. po"\
"s: 16\nPep. size: 1\nPep. mass: 165.19188"\
"\nPep. pI: 5.54\nSequence: F\n]\n"
"\nPep. pI: 5.97\nSequence: F\n]\n"
# Test fasta file
fasta_file = tmpdir.join("test.fasta")
......@@ -376,28 +376,28 @@ def test_digest_from_input(capsys, tmpdir):
"[Original header: Fake1\nNo. peptide: 0\n"\
"Enzyme: fake_enzyme1\nCleav. pos: 4\nPep."\
" size: 4\nPep. mass: 534.52598\nPep. pI: "\
"3.6\nSequence: WQSD\n, Original header: F"\
"3.14\nSequence: WQSD\n, Original header: F"\
"ake1\nNo. peptide: 1\nEnzyme: fake_enzyme"\
"1\nCleav. pos: 7\nPep. size: 3\nPep. mass"\
": 349.29758\nPep. pI: 3.4\nSequence: ESD"\
": 349.29758\nPep. pI: 3.04\nSequence: ESD"\
"\n, Original header: Fake1\nNo. peptide: "\
"2\nEnzyme: fake_enzyme1\nCleav. pos: 12\n"\
"Pep. size: 5\nPep. mass: 495.48938\nPep. "\
"pI: 3.6\nSequence: FZQSD\n, Original head"\
"pI: 3.14\nSequence: FZQSD\n, Original head"\
"er: Fake1\nNo. peptide: 3\nEnzyme: fake_e"\
"nzyme1\nCleav. pos: 15\nPep. size: 3\nPep"\
". mass: 349.29758\nPep. pI: 3.4\nSequence"\
". mass: 349.29758\nPep. pI: 3.04\nSequence"\
": ESD\n, Original header: Fake1\nNo. pept"\
"ide: 4\nEnzyme: fake_enzyme1\nCleav. pos:"\
" 16\nPep. size: 1\nPep. mass: 165.19188\n"\
"Pep. pI: 5.54\nSequence: F\n]\n"
"Pep. pI: 5.97\nSequence: F\n]\n"
assert res[1][0].__repr__() == "Number of cleavage: 0\nNumber of miscle"\
"avage: 0\nPositions of miscleavage: []"\
"\nRatio of miscleavage: 0\nPeptides: [O"\
"riginal header: Fake2\nNo. peptide: 0\nEn"\
"zyme: fake_enzyme1\nCleav. pos: 0\nPep. s"\
"ize: 15\nPep. mass: 2014.35098\nPep. pI: "\
"6.91\nSequence: NPHARDORCOMPLET\n]\n"
"7.16\nSequence: NPHARDORCOMPLET\n]\n"
# Test fastq file (same result)
fastq_file = tmpdir.join("test.fastq")
......@@ -410,25 +410,25 @@ def test_digest_from_input(capsys, tmpdir):
"[Original header: Fake1\nNo. peptide: 0\n"\
"Enzyme: fake_enzyme1\nCleav. pos: 4\nPep."\
" size: 4\nPep. mass: 534.52598\nPep. pI: "\
"3.6\nSequence: WQSD\n, Original header: F"\
"3.14\nSequence: WQSD\n, Original header: F"\
"ake1\nNo. peptide: 1\nEnzyme: fake_enzyme"\
"1\nCleav. pos: 7\nPep. size: 3\nPep. mass"\
": 349.29758\nPep. pI: 3.4\nSequence: ESD"\
": 349.29758\nPep. pI: 3.04\nSequence: ESD"\
"\n, Original header: Fake1\nNo. peptide: "\
"2\nEnzyme: fake_enzyme1\nCleav. pos: 12\n"\
"Pep. size: 5\nPep. mass: 495.48938\nPep. "\
"pI: 3.6\nSequence: FZQSD\n, Original head"\
"pI: 3.14\nSequence: FZQSD\n, Original head"\
"er: Fake1\nNo. peptide: 3\nEnzyme: fake_e"\
"nzyme1\nCleav. pos: 15\nPep. size: 3\nPep"\
". mass: 349.29758\nPep. pI: 3.4\nSequence"\
". mass: 349.29758\nPep. pI: 3.04\nSequence"\
": ESD\n, Original header: Fake1\nNo. pept"\
"ide: 4\nEnzyme: fake_enzyme1\nCleav. pos:"\
" 16\nPep. size: 1\nPep. mass: 165.19188\n"\
"Pep. pI: 5.54\nSequence: F\n]\n"
"Pep. pI: 5.97\nSequence: F\n]\n"
assert res[1][0].__repr__() == "Number of cleavage: 0\nNumber of miscle"\
"avage: 0\nPositions of miscleavage: []"\
"\nRatio of miscleavage: 0\nPeptides: [O"\
"riginal header: Fake2\nNo. peptide: 0\nEn"\
"zyme: fake_enzyme1\nCleav. pos: 0\nPep. s"\
"ize: 15\nPep. mass: 2014.35098\nPep. pI: "\
"6.91\nSequence: NPHARDORCOMPLET\n]\n"
"7.16\nSequence: NPHARDORCOMPLET\n]\n"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment