Ejemplo n.º 1
0
def main():
    """
    Main method for the script
    """

    args = get_args()
    file = list(nmrstarlib.read_files(args.restraints))[0]
    restraints = file["save_CNS/XPLOR_distance_constraints_2"]["loop_1"]

    for r in restraints[1]:

        id1 = r[SEQ1]
        res1 = r[COMP1]
        atom1 = r[ATOM1]

        id2 = r[SEQ2]
        res2 = r[COMP2]
        atom2 = r[ATOM2]

        if res1 in COLORS and res2 in COLORS:
            if (ATOM_EXPR.match(atom1) is not None
                    and ATOM_EXPR.match(atom2) is not None):

                if res1 == "ILE":
                    label1 = f"I{id1}"
                else:
                    label1 = f"{res1[0]}{id1}.{atom1[-1]}"

                if res2 == "ILE":
                    label2 = f"I{id2}"
                else:
                    label2 = f"{res2[0]}{id2}.{atom2[-1]}"

                print(label1, label2)
Ejemplo n.º 2
0
def LoadNMRCS(BMRBID, FOLDER):
    """Load a file in NMRSTAR 3.1 format and get Chemical shift data."""
    # print(FOLDER+BMRBID)
    starfiles = nmrstarlib.read_files(FOLDER + BMRBID)
    starfile = starfile = list(starfiles)
    keyList = list(starfile[0].keys())
    indices = [i for i, s in enumerate(keyList) if 'comment' in s]
    df, iNum = getCS(starfile, keyList, indices)
    return df, iNum
Ejemplo n.º 3
0
def test_converter_module(from_path, to_path, from_format, to_format):
    nmrstar_file_translator = StarFileToStarFile(from_path=from_path,
                                                 to_path=to_path,
                                                 from_format=from_format,
                                                 to_format=to_format)
    converter = Converter(file_generator=nmrstar_file_translator)
    converter.convert()

    starfile_generator = nmrstarlib.read_files(to_path)
    starfiles_list = list(starfile_generator)
    starfiles_ids_set = set(sf.id for sf in starfiles_list)
    assert starfiles_ids_set.issubset({"15000", "18569", "2RPV", "2FRG"})
def test_converter_module(from_path, to_path, from_format, to_format):
    nmrstar_file_translator = StarFileToStarFile(from_path=from_path,
                                                 to_path=to_path,
                                                 from_format=from_format,
                                                 to_format=to_format)
    converter = Converter(file_generator=nmrstar_file_translator)
    converter.convert()

    starfile_generator = nmrstarlib.read_files(to_path)
    starfiles_list = list(starfile_generator)
    starfiles_ids_set = set(sf.id for sf in starfiles_list)
    assert starfiles_ids_set.issubset({"15000", "18569", "2RPV", "2FRG"})
Ejemplo n.º 5
0
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

    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(amino_acids=amino_acids,
                                                         atoms=atoms,
                                                         amino_acids_and_atoms=amino_acids_and_atoms,
                                                         nmrstar_version="3")

    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(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)
Ejemplo n.º 6
0
def test_from_local_file(source):
    starfile_generator = nmrstarlib.read_files(*source)
    starfiles_list = list(starfile_generator)
    starfiles_ids_set = set(sf.id for sf in starfiles_list)
    assert starfiles_ids_set.issubset({"18569", "2RPV"})
Ejemplo n.º 7
0
def test_reading(source):
    starfile_generator = nmrstarlib.read_files(source)
    starfiles_list = list(starfile_generator)
    starfiles_ids_set = set(sf.id for sf in starfiles_list)
    assert starfiles_ids_set.issubset({"15000", "18569", "2RPV", "2FRG"})
Ejemplo n.º 8
0
def test_from_url(source):
    starfile_generator = nmrstarlib.read_files(*source)
    starfile1 = next(starfile_generator)
    starfile2 = next(starfile_generator)
    assert starfile1.id in ("15000", "18569") and starfile2.id in ("15000",
                                                                   "18569")
def test_from_local_file(source):
    starfile_generator = nmrstarlib.read_files(*source)
    starfiles_list = list(starfile_generator)
    starfiles_ids_set = set(sf.id for sf in starfiles_list)
    assert starfiles_ids_set.issubset({"18569", "2RPV"})
def test_reading(source):
    starfile_generator = nmrstarlib.read_files(source)
    starfiles_list = list(starfile_generator)
    starfiles_ids_set = set(sf.id for sf in starfiles_list)
    assert starfiles_ids_set.issubset({"15000", "18569", "2RPV", "2FRG"})
def test_from_url(source):
    starfile_generator = nmrstarlib.read_files(*source)
    starfile1 = next(starfile_generator)
    starfile2 = next(starfile_generator)
    assert starfile1.id in ("15000", "18569") and starfile2.id in ("15000", "18569")