예제 #1
0
def test_determine_b_group_calpha_true():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/1a1q.pdb"
    pdb_id = "1a1q"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["calpha_only"], True)
예제 #2
0
def test_determine_b_group_nucleic_None():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/1av1.pdb"
    pdb_id = "1av1"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["nucleic_b"], None)
예제 #3
0
def test_determine_b_group_protein_2ADP():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/3zzt.pdb"
    pdb_id = "3zzt"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "residue_2ADP")
예제 #4
0
def test_determine_b_group_calpha_true_3():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/1efg.pdb"
    pdb_id = "1efg"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "overall")
    eq_(result["calpha_only"], True)
예제 #5
0
def test_determine_b_group_protein_no_b_factors():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/1mcb.pdb"
    pdb_id = "1mcb"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "no_b-factors")
    eq_(result["calpha_only"], False)
    eq_(result["nucleic_b"], None)
예제 #6
0
def test_determine_b_group_nucleic_individual():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/100d.pdb"
    pdb_id = "100d"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], None)
    eq_(result["calpha_only"], False)
    eq_(result["nucleic_b"], "individual")
예제 #7
0
def test_determine_b_group_nucleic_2ADP():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/1hlz.pdb"
    pdb_id = "1hlz"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "residue_1ADP")
    eq_(result["calpha_only"], False)
    eq_(result["nucleic_b"], "residue_2ADP")
예제 #8
0
def test_determine_b_group_protein_overall():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/1etu.pdb"
    pdb_id = "1etu"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "overall")
    eq_(result["calpha_only"], False)
    eq_(result["nucleic_b"], None)
예제 #9
0
def test_determine_b_group_too_short():
    """Tests that b_group is correctly determined."""
    pdb_file_path = "pdbb/tests/pdb/files/438d.pdb"
    pdb_id = "438d"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], None)
    eq_(result["calpha_only"], False)
    eq_(result["nucleic_b"], None)
    eq_(result["phos_only"], False)
예제 #10
0
def test_determine_b_group_protein_overall_4():
    """Tests that b_group is correctly determined.

        1av1 has the same B-factor for large stretches
        of residues; overall is probably the best term.
    """
    pdb_file_path = "pdbb/tests/pdb/files/1av1.pdb"
    pdb_id = "1av1"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "overall")
예제 #11
0
def test_determine_b_group_protein_overall_3():
    """Tests that b_group is correctly determined.

        1c2y has the same B-factor everywhere,
        except for some THR and LEU atoms end-of-side-chain
        overall is probably the best term.
    """
    pdb_file_path = "pdbb/tests/pdb/files/1c2y.pdb"
    pdb_id = "1c2y"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "overall")
    eq_(result["calpha_only"], False)
    eq_(result["nucleic_b"], None)
예제 #12
0
def test_determine_b_group_protein_overall_2():
    """Tests that b_group is correctly determined.

        1az2 is has 16.67 for all N CA and C atoms
        and 20.54 for O and side-chain atoms.
        overall is probably the best term.
    """
    pdb_file_path = "pdbb/tests/pdb/files/1az2.pdb"
    pdb_id = "1az2"
    structure = get_structure(pdb_file_path, pdb_id)
    result = determine_b_group(structure)
    eq_(result["protein_b"], "overall")
    eq_(result["calpha_only"], False)
    eq_(result["nucleic_b"], None)
예제 #13
0
def create_bdb_entry(pdb_file_path, pdb_id, verbose=False):
    """Create a bdb entry.

    Return True when a bdb has been created successfully.
    """

    _log.debug("Creating bdb entry...")

    # Parse the given pdb file into a dict...
    pdb_records = parse_pdb_file(pdb_file_path)

    # and a Biopython structure
    structure = get_structure(pdb_file_path, pdb_id, verbose)

    bdbd = {"pdb_id": pdb_id}
    expdta = check_exp_methods(pdb_records, pdb_id)
    bdbd.update(expdta)
    created_bdb_file = False
    if expdta["expdta_useful"]:
        refi_data = get_refi_data(pdb_records, structure, pdb_id)
        bdbd.update(refi_data)

        # Info about B-factor group type
        b_group = determine_b_group(structure)
        bdbd.update(b_group)

        # skttles outliers
        skttls = {"skttls_tot": None, "skttls_95th": None, "skttls_99th": None}
        bdbd.update(skttls)

        if refi_data["is_bdb_includable"]:
            bdb_file_dir = pyconfig.get("BDB_FILE_DIR_PATH")
            bdb_file_path = os.path.join(bdb_file_dir, pdb_id + ".bdb")
            if refi_data["req_tlsanl"]:
                if run_tlsanl(pdb_file_path=pdb_file_path,
                              xyzout=bdb_file_path,
                              pdb_id=pdb_id,
                              log_out_dir=bdb_file_dir):
                    created_bdb_file = True
                    tlsanl_log = os.path.join(bdb_file_dir,
                                              pyconfig.get("TLSANL_LOG"))
                    skttls = parse_skttls_summ(tlsanl_log=tlsanl_log)
                    bdbd.update(skttls)

            elif refi_data["b_msqav"]:
                if write_multiplied_8pipi(pdb_file_path=pdb_file_path,
                                          xyzout=bdb_file_path,
                                          pdb_id=pdb_id,
                                          verbose=verbose):
                    created_bdb_file = True

            elif refi_data["assume_iso"]:
                shutil.copy(pdb_file_path, bdb_file_path)
                created_bdb_file = True

            else:
                message = "Unexpected bdb status"
                write_whynot(pdb_id, message)
                _log.error("{}.".format(message))

        # Write the bdb metadata to a json file
        try:
            with open(
                    os.path.join(pyconfig.get("BDB_FILE_DIR_PATH"),
                                 pdb_id + ".json"), "w") as f:
                json.dump(bdbd,
                          f,
                          sort_keys=True,
                          indent=4,
                          default=date_handler)
        except IOError as ex:
            _log.error(ex)
            return False

    return created_bdb_file