-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,52 @@ | ||
import json | ||
from collections import OrderedDict | ||
from nmrstarlib import nmrstarlib | ||
|
||
import collections | ||
import pytest | ||
|
||
def test_chem_shifts_by_residue_all(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/bmr18569.str", | ||
"tests/example_data/NMRSTAR2/bmr18569.str") | ||
starfile1 = next(starfile_generator) | ||
starfile2 = next(starfile_generator) | ||
test_chem_shifts1 = starfile1.chem_shifts_by_residue(nmrstar_version="3") | ||
test_chem_shifts2 = starfile2.chem_shifts_by_residue(nmrstar_version="2") | ||
from nmrstarlib import nmrstarlib | ||
|
||
with open("tests/example_data/NMRSTAR3/chem_shifts_by_residue_all.json", "r") as infile: | ||
model_chem_shifts1 = json.load(infile, object_pairs_hook=OrderedDict) | ||
with open("tests/example_data/NMRSTAR2/chem_shifts_by_residue_all.json", "r") as infile: | ||
model_chem_shifts2 = json.load(infile, object_pairs_hook=OrderedDict) | ||
|
||
assert repr(test_chem_shifts1) == repr(model_chem_shifts1) | ||
assert repr(test_chem_shifts2) == repr(model_chem_shifts2) | ||
@pytest.mark.parametrize("test_input,test_output,amino_acids,atoms,amino_acids_and_atoms", [ | ||
(("tests/example_data/NMRSTAR3/bmr18569.str", "tests/example_data/NMRSTAR2/bmr18569.str"), | ||
("tests/example_data/NMRSTAR3/chem_shifts_by_residue_all.json", "tests/example_data/NMRSTAR2/chem_shifts_by_residue_all.json"), | ||
None, None, None), | ||
(("tests/example_data/NMRSTAR3/bmr18569.str", "tests/example_data/NMRSTAR2/bmr18569.str"), | ||
("tests/example_data/NMRSTAR3/chem_shifts_by_residue_SER.json", "tests/example_data/NMRSTAR2/chem_shifts_by_residue_SER.json"), | ||
["SER"], None, None), | ||
def test_chem_shifts_by_residue_amino_acids_list(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/bmr18569.str", | ||
"tests/example_data/NMRSTAR2/bmr18569.str") | ||
starfile1 = next(starfile_generator) | ||
starfile2 = next(starfile_generator) | ||
test_chem_shifts1 = starfile1.chem_shifts_by_residue(amino_acids=("SER",), nmrstar_version="3") | ||
test_chem_shifts2 = starfile2.chem_shifts_by_residue(amino_acids=("SER",), nmrstar_version="2") | ||
(("tests/example_data/NMRSTAR3/bmr18569.str", "tests/example_data/NMRSTAR2/bmr18569.str"), | ||
("tests/example_data/NMRSTAR3/chem_shifts_by_residue_CA_CB.json", "tests/example_data/NMRSTAR2/chem_shifts_by_residue_CA_CB.json"), | ||
None, ["CA", "CB"], None), | ||
with open("tests/example_data/NMRSTAR3/chem_shifts_by_residue_SER.json", "r") as infile: | ||
model_chem_shifts1 = json.load(infile, object_pairs_hook=OrderedDict) | ||
with open("tests/example_data/NMRSTAR2/chem_shifts_by_residue_SER.json", "r") as infile: | ||
model_chem_shifts2 = json.load(infile, object_pairs_hook=OrderedDict) | ||
(("tests/example_data/NMRSTAR3/bmr18569.str", "tests/example_data/NMRSTAR2/bmr18569.str"), | ||
("tests/example_data/NMRSTAR3/chem_shifts_by_residue_SER_CA_CB.json", "tests/example_data/NMRSTAR2/chem_shifts_by_residue_SER_CA_CB.json"), | ||
["SER"], ["CA", "CB"], None), | ||
assert repr(test_chem_shifts1) == repr(model_chem_shifts1) | ||
assert repr(test_chem_shifts2) == repr(model_chem_shifts2) | ||
(("tests/example_data/NMRSTAR3/bmr18569.str", "tests/example_data/NMRSTAR2/bmr18569.str"), | ||
("tests/example_data/NMRSTAR3/chem_shifts_by_residue_SER_HA_CA_MET_CA_CB.json", "tests/example_data/NMRSTAR2/chem_shifts_by_residue_SER_HA_CA_MET_CA_CB.json"), | ||
None, None, {"SER":["HA", "CA"], "MET":["CA", "CB"]}) | ||
]) | ||
def test_chem_shifts_by_residue_all(test_input, test_output, amino_acids, atoms, amino_acids_and_atoms): | ||
input_file_path1, input_file_path2 = test_input | ||
output_file_path1, output_file_path2 = test_output | ||
|
||
def test_chem_shifts_by_residue_atoms_list(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/bmr18569.str", | ||
"tests/example_data/NMRSTAR2/bmr18569.str") | ||
starfile_generator = nmrstarlib.read_files(input_file_path1, input_file_path2) | ||
starfile1 = next(starfile_generator) | ||
starfile2 = next(starfile_generator) | ||
test_chem_shifts1 = starfile1.chem_shifts_by_residue(atoms=("CA", "CB"), nmrstar_version="3") | ||
test_chem_shifts2 = starfile2.chem_shifts_by_residue(atoms=("CA", "CB"), nmrstar_version="2") | ||
|
||
with open("tests/example_data/NMRSTAR3/chem_shifts_by_residue_CA_CB.json", "r") as infile: | ||
model_chem_shifts1 = json.load(infile, object_pairs_hook=OrderedDict) | ||
with open("tests/example_data/NMRSTAR2/chem_shifts_by_residue_CA_CB.json", "r") as infile: | ||
model_chem_shifts2 = json.load(infile, object_pairs_hook=OrderedDict) | ||
test_chem_shifts1 = starfile1.chem_shifts_by_residue(amino_acids=amino_acids, | ||
atoms=atoms, | ||
amino_acids_and_atoms=amino_acids_and_atoms, | ||
nmrstar_version="3") | ||
|
||
assert repr(test_chem_shifts1) == repr(model_chem_shifts1) | ||
assert repr(test_chem_shifts2) == repr(model_chem_shifts2) | ||
|
||
|
||
def test_chem_shifts_by_residue_amino_acids_list_atoms_list(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/bmr18569.str", | ||
"tests/example_data/NMRSTAR2/bmr18569.str") | ||
starfile1 = next(starfile_generator) | ||
starfile2 = next(starfile_generator) | ||
test_chem_shifts1 = starfile1.chem_shifts_by_residue(amino_acids=("SER",), atoms=("CA", "CB"), nmrstar_version="3") | ||
test_chem_shifts2 = starfile2.chem_shifts_by_residue(amino_acids=("SER",), atoms=("CA", "CB"), nmrstar_version="2") | ||
test_chem_shifts2 = starfile2.chem_shifts_by_residue(amino_acids=amino_acids, | ||
atoms=atoms, | ||
amino_acids_and_atoms=amino_acids_and_atoms, | ||
nmrstar_version="2") | ||
|
||
with open("tests/example_data/NMRSTAR3/chem_shifts_by_residue_SER_CA_CB.json", "r") as infile: | ||
model_chem_shifts1 = json.load(infile, object_pairs_hook=OrderedDict) | ||
with open("tests/example_data/NMRSTAR2/chem_shifts_by_residue_SER_CA_CB.json", "r") as infile: | ||
model_chem_shifts2 = json.load(infile, object_pairs_hook=OrderedDict) | ||
with open(output_file_path1, "r") as infile: | ||
model_chem_shifts1 = json.load(infile, object_pairs_hook=collections.OrderedDict) | ||
with open(output_file_path2, "r") as infile: | ||
model_chem_shifts2 = json.load(infile, object_pairs_hook=collections.OrderedDict) | ||
|
||
assert repr(test_chem_shifts1) == repr(model_chem_shifts1) | ||
assert repr(test_chem_shifts2) == repr(model_chem_shifts2) | ||
|
||
def test_chem_shifts_by_residue_amino_acids_and_atoms_dict(): | ||
starfile_generator = nmrstarlib.read_files("tests/example_data/NMRSTAR3/bmr18569.str", | ||
"tests/example_data/NMRSTAR2/bmr18569.str") | ||
starfile1 = next(starfile_generator) | ||
starfile2 = next(starfile_generator) | ||
test_chem_shifts1 = starfile1.chem_shifts_by_residue(amino_acids_and_atoms={"SER":("HA", "CA"), "MET":("CA", "CB")}, nmrstar_version="3") | ||
test_chem_shifts2 = starfile2.chem_shifts_by_residue(amino_acids_and_atoms={"SER":("HA", "CA"), "MET":("CA", "CB")}, nmrstar_version="2") | ||
|
||
with open("tests/example_data/NMRSTAR3/chem_shifts_by_residue_SER_HA_CA_MET_CA_CB.json", "r") as infile: | ||
model_chem_shifts1 = json.load(infile, object_pairs_hook=OrderedDict) | ||
with open("tests/example_data/NMRSTAR2/chem_shifts_by_residue_SER_HA_CA_MET_CA_CB.json", "r") as infile: | ||
model_chem_shifts2 = json.load(infile, object_pairs_hook=OrderedDict) | ||
|
||
assert repr(test_chem_shifts1) == repr(model_chem_shifts1) | ||
assert repr(test_chem_shifts2) == repr(model_chem_shifts2) |