コード例 #1
0
    def test_parse_remark_2__resolution_info(self):
        pdb_1HFF = pdb.from_file(self.pdb_1HFF)
        info_1HFF = pdb_info(pdb_1HFF)
        resseq = pdb_1HFF.get_resseq_as_chaindict()
        self.assertIsInstance(info_1HFF, pdb_info)
        self.assertRaises(ValueError, info_1HFF.parse_remark_2)

        pdb_4xia = pdb.from_file(self.pdb_4xia)
        info_4xia = pdb_info(pdb_4xia)
        self.assertIsInstance(info_4xia, pdb_info)
        info_4xia.parse_remark_2()
        self.assertEqual(info_4xia.Resolution_Grade, 'Good')
コード例 #2
0
 def test_parse_remark_3__get_r_free_grade_first_r_free(self):
     pdb_2v2h = pdb.from_file(self.pdb_2v2h)
     info_2v2h = pdb_info(pdb_2v2h)
     self.assertIsInstance(info_2v2h, pdb_info)
     info_2v2h.parse_remark_2()
     info_2v2h.parse_remark_3()
     self.assertEqual(info_2v2h.R_free, '0.1868')
コード例 #3
0
ファイル: pdb_info.py プロジェクト: jcheminform/pdb_prep
def diff(pdb_file, out_file, chain_a, chain_b, model_a, model_b, verbose
         ):  # , chain_id_a, chain_id_b, model_num_a, model_num_b,verbose):
    """compare two peptides"""
    cliutils = cu(click, is_verbose=verbose)
    if not os.path.isfile(pdb_file):
        cliutils.exit(1, "ERROR", "no such file:{}".format(pdb_file))

    if not pdb_file.lower().endswith(".pdb"):
        cliutils.exit(2, "ERROR", "not a pdb file: {}".format(pdb_file))

    if not out_file:
        out_short_name = os.path.basename(pdb_file, )
        out_short_name = os.path.splitext(out_short_name)[0]
        out_short_name = out_short_name + '-diff.html'
        out_file = os.path.join(os.getcwd(), out_short_name)

    _pdb = pdb.from_file(pdb_file)
    chain_a = _pdb.get_chain(str(model_a), str(chain_a))
    chain_b = _pdb.get_chain(str(model_b), str(chain_b))
    _chains_comapre = chains_comapre()
    print("start diff...", flush=True)
    diff = _chains_comapre.comapre_two_chains(chain_a, chain_b)
    print("end diff...", flush=True)
    with open(out_file, "w") as htf:
        htf.write(diff)
    click.echo("diff is is in: {}".format(out_file))
    return 0
コード例 #4
0
def sym_axis(input_file, axis, verbose):
    """
    \b
    calculates the distance of each amino acid from the symmetry axis.
    homomer symmetric axis distance
    """
    _caller = "atoms_pairs command"
    cliutils = cu(click, is_verbose=verbose)

    _axis = validate_trimer_options(cliutils, input_file, axis, verbose)
    mypdb = pdb.from_file(input_file)
    atoms_names = ["CA", "CB"]
    results = []
    vector3d = point_3d(*_axis)
    for atom_name in atoms_names:
        siever = atom_names_siever(atom_name)
        for model in mypdb:
            for chain in model:
                msg = "atom:{:<3} model number:{} ,chain_id: {}"
                cliutils.verbose(msg.format(atom_name, model.model_number,
                                            chain.chain_id),
                                 caller=_caller)
                is_match = lambda atom: siever.is_match(atom, atom_name)
                current_results = symetric_axis_distance.dist_from_vector(
                    input_file=input_file,
                    model_number=model.model_number,
                    chain_id=chain.chain_id,
                    atoms=filter(is_match, chain),
                    vector3d=vector3d)
                results.extend(current_results)
    symetric_axis_distance.print_results(results)
コード例 #5
0
    def test_parse_remark_350(self):
        pdb_4xia = pdb.from_file(self.pdb_4xia)
        info_4xia = pdb_info(pdb_4xia)
        self.assertIsInstance(info_4xia, pdb_info)
        info_4xia.parse_remark_350()
        self.assertEqual(info_4xia.bio_struct_identical_to_the_asymmetric_unit,
                         False)

        pdb_1g2y = pdb.from_file(self.pdb_1g2y)
        info_1g2y = pdb_info(pdb_1g2y)
        self.assertIsInstance(info_1g2y, pdb_info)
        info_1g2y.parse_remark_350(bio_molecule_chains=4)
        self.assertEqual(info_1g2y.bio_struct_identical_to_the_asymmetric_unit,
                         True, 'unit matrix with all peptides')

        info_1g2y = pdb_info(pdb_1g2y)
        info_1g2y.parse_remark_350(bio_molecule_chains=1)
        self.assertEqual(info_1g2y.bio_struct_identical_to_the_asymmetric_unit,
                         False)

        pdb_3cwr = pdb.from_file(self.pdb_3cwr)
        info_3cwr = pdb_info(pdb_3cwr)
        self.assertIsInstance(info_3cwr, pdb_info)
        info_3cwr.parse_remark_350()
        self.assertEqual(info_3cwr.bio_struct_identical_to_the_asymmetric_unit,
                         False, 'unit matrix with part of the peptides')

        pdb_3mux = pdb.from_file(self.pdb_3mux)
        info_3mux = pdb_info(pdb_3mux)
        self.assertIsInstance(info_3mux, pdb_info)
        info_3mux.parse_remark_350()
        self.assertEqual(info_3mux.bio_struct_identical_to_the_asymmetric_unit,
                         False, 'not a unit matrix')

        pdb_3mwj = pdb.from_file(self.pdb_3mwj)
        info_3mwj = pdb_info(pdb_3mwj)
        self.assertIsInstance(info_3mwj, pdb_info)
        info_3mwj.parse_remark_350()
        self.assertEqual(info_3mwj.bio_struct_identical_to_the_asymmetric_unit,
                         False, ' missing remark 350')
コード例 #6
0
    def test_parse_remark_465_get_r_free_grade(self):
        pdb_5tor = pdb.from_file(self.pdb_5tor)
        info_5tor = pdb_info(pdb_5tor)
        self.assertIsInstance(info_5tor, pdb_info)
        info_5tor.parse_remark_465()
        missing_residues = info_5tor.missing_residues
        # REMARK 465   M RES C SSSEQI
        # REMARK 465     GLN B   412
        # REMARK 470

        self.assertEqual(len(missing_residues), 1)
        self.assertEqual(missing_residues[0]["resname"], "GLN")
        self.assertEqual(missing_residues[0]["chain_id"], "B")
コード例 #7
0
 def test_parse_remark_470_get_r_free_grade(self):
     pdb_5tor = pdb.from_file(self.pdb_5tor)
     info_1tor = pdb_info(pdb_5tor)
     self.assertIsInstance(info_1tor, pdb_info)
     info_1tor.parse_remark_470()
     missing_atoms = info_1tor.missing_atoms
     # REMARK 470   M RES CSSEQI  ATOMS
     # REMARK 470     ALA B   1    CA
     # REMARK 470     GLN B  13    CD
     # REMARK 500
     self.assertEqual(len(missing_atoms), 2)
     self.assertEqual(missing_atoms[0]["resname"], "ALA")
     self.assertEqual(missing_atoms[1]["atom_names"], ["CD"])
コード例 #8
0
    def test_parse_remark_3__get_r_free_grade(self):
        pdb_1HFF = pdb.from_file(self.pdb_1HFF)
        info_1HFF = pdb_info(pdb_1HFF)
        self.assertIsInstance(info_1HFF, pdb_info)
        self.assertRaises(ValueError, info_1HFF.parse_remark_3)

        pdb_4xia = pdb.from_file(self.pdb_4xia)
        info_4xia = pdb_info(pdb_4xia)
        self.assertIsInstance(info_4xia, pdb_info)
        info_4xia.parse_remark_2()
        info_4xia.parse_remark_3()
        self.assertEqual(info_4xia.R_free_grade, 'NULL')
        self.assertEqual(info_4xia.R_value, '0.147')

        pdb_2Z = pdb.from_file(self.pdb_2ZVK_missingRES)
        info_2Z = pdb_info(pdb_2Z)
        self.assertIsInstance(info_2Z, pdb_info)
        info_2Z.parse_remark_2()
        info_2Z.parse_remark_3()
        self.assertEqual(info_2Z.Resolution_Grade, 'Good/Fair')
        self.assertEqual(info_2Z.R_value, '0.215')
        self.assertEqual(info_2Z.R_free_grade,
                         'Worse than average at this resolution')
コード例 #9
0
def atoms_pairs(input_file, atoms_names, verbose):
    """
    \b
    Calculates distances between matching pairs of amino acids.
    """
    _caller = "atoms_pairs command"
    cliutils = cu(click, is_verbose=verbose)

    atoms = validate_dimer_options(cliutils, input_file, atoms_names, verbose)

    mypdb = pdb.from_file(input_file)

    if len(mypdb) == 0:
        cliutils.exit(2, "ERROR",
                      "pdb_file  has no models: {}".format(input_file))
        exit(2)
    cliutils.verbose("{}".format(mypdb.info()), _caller)
    results = []
    for atom in atoms:
        for model in mypdb:
            cliutils.verbose("atom:{:<3} model number:{}".format(
                atom, model.model_number),
                             caller=_caller)
            if len(model) != 2:
                msg = "atom:{:<3} model number: {} is not atoms_pairs (has {} chains) in pdb_file '{}'"
                cliutils.warn_msg(msg.format(atom, model.model_number,
                                             len(model), input_file),
                                  caller=_caller)
                continue
            cliutils.verbose("This is atoms_pairs (has two chains)...",
                             caller=_caller)

            eqviv_atm = eqvivalent_atoms()
            pairs_of_atoms = eqviv_atm.get_pairs_tupels(model, atom)
            if len(pairs_of_atoms) == 0:
                msg = "atom:{:<3} model number: {} - could not find {} pairs in {}"
                cliutils.warn_msg(msg.format(atom, model.model_number, atom,
                                             len(model), input_file),
                                  caller=_caller)
            current_results = protein_dimer_distance.dist_pairs(
                input_file, model.model_number, pairs_of_atoms)
            results.extend(current_results)

    protein_dimer_distance.print_results(results)
    return results
コード例 #10
0
ファイル: inform.py プロジェクト: jcheminform/pdb_prep
def create_pdb_info(file,
                    dir_path,
                    include_hetatm,
                    ignore_remarks=[],
                    output_type='text',
                    bio_molecule_chains=None,
                    is_verbose=False):
    start_time = time.time()
    _file_path = os.path.join(dir_path, file)
    _pdb = pdb.from_file(_file_path, include_hetatm=include_hetatm)
    pdbinfo = pdb_info(_pdb,
                       ignore_remarks=ignore_remarks,
                       bio_molecule_chains=bio_molecule_chains,
                       output_type=output_type)
    if is_verbose:
        print(" create_pdb_info iter execution time = {0:.5f} ".format(
            time.time() - start_time))

    return pdbinfo
コード例 #11
0
 def test_one_peptide(self):
     mypdb = pdb.from_file(self.one_peptide)
     self.assertIsInstance(mypdb, pdb)
     self.assertEqual(mypdb.get_number_of_models(), 1)
コード例 #12
0
 def test_two_peptides_no_model(self):
     mypdb = pdb.from_file(self.two_peptides_no_model)
     self.assertIsInstance(mypdb, pdb)
     self.assertEqual(mypdb.get_number_of_models(), 1)
コード例 #13
0
 def test_is_homomer_2v2h(self):
     pdb_2v2h = pdb.from_file(self.pdb_2v2h)
     info_2v2h = pdb_info(pdb_2v2h)
     self.assertIsInstance(info_2v2h, pdb_info)
     self.assertEqual(info_2v2h.is_homomer(), True)
コード例 #14
0
 def test_1HFF(self):
     mypdb = pdb.from_file(self.pdb_1HFF)
     models_numbers = list(map(lambda m: m.model_number, mypdb))
     self.assertIsInstance(mypdb, pdb)
     self.assertEqual(models_numbers, list(map(str, range(1, 56))))
コード例 #15
0
 def test_is_homomer_4xia(self):
     pdb_4xia = pdb.from_file(self.pdb_4xia)
     info_4xia = pdb_info(pdb_4xia)
     self.assertIsInstance(info_4xia, pdb_info)
     self.assertEqual(info_4xia.is_homomer(), True)
コード例 #16
0
 def test_is_homomer_1HFF(self):
     pdb_1HFF = pdb.from_file(self.pdb_1HFF)
     info_1HFF = pdb_info(pdb_1HFF)
     self.assertIsInstance(info_1HFF, pdb_info)
     self.assertEqual(info_1HFF.is_homomer(), True)
コード例 #17
0
 def test_1aib(self):
     mypdb = pdb.from_file(self.pdb_1aib)
     chains_ids = list(map(lambda m: m.chain_id, mypdb[0]))
     self.assertIsInstance(mypdb, pdb)
     self.assertEqual(chains_ids, ['A', 'B'])
     self.assertEqual(set(mypdb.remarks.keys()), set([99]))
コード例 #18
0
 def test_two_model_peptides(self):
     mypdb = pdb.from_file(self.two_model_peptides)
     self.assertIsInstance(mypdb, pdb)
     self.assertEqual(mypdb.get_number_of_models(), 2)
     model = mypdb[0]
     self.assertEqual(model.get_number_of_chains(), 1)
コード例 #19
0
 def test_with_hetatm(self):
     mypdb = pdb.from_file(self.with_hetatm, include_hetatm=True)
     self.assertIsInstance(mypdb, pdb)
     self.assertEqual(mypdb.get_number_of_models(), 1)
     self.assertEqual(mypdb[0].get_number_of_chains(), 2)