Skip to content

Commit

Permalink
Added additional tests for 'csview' command.
Browse files Browse the repository at this point in the history
  • Loading branch information
smelandr committed Oct 23, 2017
1 parent b352b97 commit 8c4809a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
6 changes: 3 additions & 3 deletions nmrstarlib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
--bmrb_url=<url> URL to BMRB REST interface [default: http://rest.bmrb.wisc.edu/bmrb/NMR-STAR3/].
--aa=<aa> Comma-separated amino acid three-letter codes (e.g. --aa=ALA,SER).
--at=<at> Comma-separated BMRB atom codes (e.g. --at=CA,CB).
--aa_at=<aa:at> Comma-separated amino acid three-letter codes and corresponding atoms (e.g. --aa_at=ALA:CA,CB;SER:CA,CB).
--aa_at=<aa:at> Comma-separated amino acid three-letter codes and corresponding atoms (e.g. --aa_at=ALA-CA,CB:LYS-CB,CG,CD).
--csview_outfile=<path> Where to save chemical shifts table.
--csview_format=<format> Format to which save chemical shift table [default: svg].
--plsplit=<%> How to split peak list into chunks by percent [default: 100].
Expand Down Expand Up @@ -61,10 +61,10 @@ def cli(cmdargs):
elif cmdargs["csview"]:
amino_acids = cmdargs["--aa"].split(",") if cmdargs["--aa"] else None
atoms = cmdargs["--at"].split(",") if cmdargs["--at"] else None

amino_acids_and_atoms = cmdargs["--aa_at"]

if amino_acids_and_atoms:
amino_acids_and_atoms_list = [pair.split(':') for pair in amino_acids_and_atoms.split(';')]
amino_acids_and_atoms_list = [pair.split('-') for pair in amino_acids_and_atoms.split(':')]
amino_acids_and_atoms = {aa: at.split(",") for aa, at in amino_acids_and_atoms_list}
else:
amino_acids_and_atoms = None
Expand Down
38 changes: 18 additions & 20 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,23 @@ def test_convert_command(from_path, to_path, from_format, to_format):
assert starfiles_ids_set.issubset({"15000", "18569"})


@pytest.mark.parametrize("from_path,amino_acids,atoms,nmrstar_version", [
("tests/example_data/NMRSTAR3/bmr18569.str", None, None, "3"),
("tests/example_data/NMRSTAR3/bmr18569.str", "SER,MET", None, "3"),
("tests/example_data/NMRSTAR3/bmr18569.str", None, "CA,CB", "3"),
("tests/example_data/NMRSTAR3/bmr18569.str", "SER,MET", "CA,CB", "3"),
("tests/example_data/NMRSTAR2/bmr18569.str", None, None, "2"),
("tests/example_data/NMRSTAR2/bmr18569.str", "SER,MET", None, "2"),
("tests/example_data/NMRSTAR2/bmr18569.str", None, "CA,CB", "2"),
("tests/example_data/NMRSTAR2/bmr18569.str", "SER,MET", "CA,CB", "2")
@pytest.mark.parametrize("from_path,amino_acids,atoms,amino_acids_and_atoms,nmrstar_version", [
("tests/example_data/NMRSTAR3/bmr18569.str", "", "", "", "3"),
("tests/example_data/NMRSTAR3/bmr18569.str", "SER,MET", "", "", "3"),
("tests/example_data/NMRSTAR3/bmr18569.str", "", "CA,CB", "", "3"),
("tests/example_data/NMRSTAR3/bmr18569.str", "SER,MET", "CA,CB", "", "3"),
("tests/example_data/NMRSTAR3/bmr18569.str", "", "", "ALA-CA,CB:LYS-CB,CG,CD", "3"),
("tests/example_data/NMRSTAR2/bmr18569.str", "", "", "", "2"),
("tests/example_data/NMRSTAR2/bmr18569.str", "SER,MET", "", "", "2"),
("tests/example_data/NMRSTAR2/bmr18569.str", "", "CA,CB", "", "2"),
("tests/example_data/NMRSTAR2/bmr18569.str", "SER,MET", "CA,CB", "", "2"),
("tests/example_data/NMRSTAR3/bmr18569.str", "", "", "ALA-CA,CB:LYS-CB,CG,CD", "2"),
])
def test_csview_command(from_path, amino_acids, atoms, nmrstar_version):
def test_csview_command(from_path, amino_acids, atoms, amino_acids_and_atoms, nmrstar_version):

if amino_acids == None and atoms == None:
command = "python -m nmrstarlib csview {} --nmrstar_version={}".format(from_path, nmrstar_version)
elif amino_acids == None and atoms != None:
command = "python -m nmrstarlib csview {} --at={} --nmrstar_version={}".format(from_path, atoms, nmrstar_version)
elif atoms == None and amino_acids != None:
command = "python -m nmrstarlib csview {} --aa={} --nmrstar_version={}".format(from_path, amino_acids, nmrstar_version)
else:
command = "python -m nmrstarlib csview {} --aa={} --at={} --nmrstar_version={}".format(from_path, amino_acids, atoms, nmrstar_version)

assert os.system(command) == 0
command = "python -m nmrstarlib csview {} --aa={} --at={} --aa_at={} --nmrstar_version={}".format(from_path,
amino_acids,
atoms,
amino_acids_and_atoms,
nmrstar_version)
assert os.system(command) == 0

0 comments on commit 8c4809a

Please sign in to comment.