コード例 #1
0
 def __init__(self, ca_trace):
     if isinstance(ca_trace, PDBStructure):
         ca_trace = pdb_to_catrace(ca_trace)
     assert isinstance(ca_trace, CaTrace)
     self.__ca_trace = ca_trace
     self.__property_estimator = OneShotPropertyEstimator(ca_trace)
     self.__sidechain_handler = BatchSideChainConfigHandler(ca_trace)
     self.__signature = {}
     self.__placement_matrix = {}
     self.__placement_vector = {}
     self.__ca_position = {}
     self.__logger = logging.getLogger("mutant_model.ResidueLookup")
def get_signatures(pdbfile, amino, property_list, nbrs):
    assert os.path.isfile(pdbfile)
    assert isinstance(property_list, list)
    assert nbrs > 2
    assert all([
        p in cg.CoarseGrainProperty.supported_properties()
        for p in property_list
    ])
    pdblist = sd.read_pdb(pdbfile)
    assert len(pdblist) > 0
    chain = list(pdblist[0].keys())[0]
    pdb = pdblist[0][chain]
    try:
        ca_trace = sd.pdb_to_catrace(pdb)
    except:
        return np.array([])
    assert isinstance(pdb, sd.PDBStructure)
    residue_ids = [r for r in pdb.residue_ids if r > 0][1:-1]
    residue_ids = [
        r for r in residue_ids if sd.get_amino(pdb.residue_name(r)) == amino
    ]
    residue_ids = cg.filter_complete_residues(pdb, residue_ids)
    vol = cg.Volume3D(size=cg.VolumeSignatureGrid.size(),
                      dim=cg.VolumeSignatureGrid.dim())
    if len(residue_ids) > 0:
        vol_signature = []
        for r in residue_ids:
            vol_signature.append(vol.get_signature(pdb, r, reset=True))
        nbr_signature = cg.cg_neighbor_signature(ca_trace,
                                                 residues=residue_ids,
                                                 properties=property_list,
                                                 topn=nbrs)
        vol_signature, nbr_signature = np.array(vol_signature), np.array(
            nbr_signature)
        if vol_signature.shape[0] == nbr_signature.shape[0]:
            return np.concatenate((nbr_signature, vol_signature), axis=1)
    return np.array([])
コード例 #3
0
    args = parser.parse_args()

    if not os.path.isfile(args.pdb_file):
        raise Exception("Can not read pdb file [%s]" % args.pdb_file)

    pdb_list = sd.read_pdb(args.pdb_file)
    chain = args.chain

    assert len(pdb_list) == 1
    neigbors = []
    r_0, r_1, r_2 = args.residue - 1, args.residue, args.residue + 1

    for pdbs in pdb_list:
        assert isinstance(pdbs, dict)
        assert chain in pdbs
        ca_trace = sd.pdb_to_catrace(pdbs[chain])
        valid_residues = ca_trace.residue_ids[1:-1]
        if args.residue not in valid_residues:
            raise Exception("Residue %d not a valid residue!" % args.residue)
        neighbors = cg.find_k_neighbors(pdb=ca_trace,
                                        residues=[args.residue],
                                        k=args.topk + 2)
        neighbors = [
            r for r, d in neighbors[args.residue] if abs(r - args.residue) > 1
        ]
        volumes = [
            cg.PropertyCalculator.volume(ca_trace, r) for r in neighbors
        ]
        hydropathy = [
            cg.PropertyCalculator.hydropathy(ca_trace, r) for r in neighbors
        ]
コード例 #4
0
    max_coordinate, min_coordinate = read_bounding_box(args.bb_file)
    for i in range(len(max_coordinate)):
        max_coordinate[i] += args.buffer
        min_coordinate[i] -= args.buffer

    trajectory = [snap[args.chain] for snap in trajectory]

    align_map = None
    if args.align_map is not None:
        align_map = parse_alignment(args.align_map)

    if args.ref_pdb is not None:
        ref_pdb = sd.read_pdb(args.ref_pdb)
        assert (len(ref_pdb) == 1) and (len(ref_pdb[0]) == 1)
        chain = list(ref_pdb[0].keys())[0]
        ref_pdb = sd.pdb_to_catrace(ref_pdb[0][chain])
        trajectory = mm.align_trajectory(ref_structure=ref_pdb,
                                         tgt_structure=trajectory[0],
                                         trajectory=trajectory,
                                         align_pair=align_map,
                                         ca_trace=True)

    signature = mm.Signature(max_coord=max_coordinate,
                             min_coord=min_coordinate)

    res_names = dict()
    for trace in trajectory:
        for res_id in trace.residue_ids:
            if res_id not in res_names:
                res_names[res_id] = trace.get_amino(res_id).name(
                    one_letter_code=False)
コード例 #5
0
import os
import time
from mutant_model import *
from structural_dynamics import read_trajectory_catrace, read_pdb, pdb_to_catrace

if __name__ == "__main__":
    pdb_file = os.path.join(os.path.dirname(__file__), 'data',
                            'structure_1a1v.pdb')
    trj_file2 = os.path.join(os.path.dirname(__file__), 'data',
                             'ex_trajectory_2.pdb')
    assert os.path.isfile(pdb_file) and os.path.isfile(trj_file2)
    ref_pdb = pdb_to_catrace(read_pdb(pdb_file)[0]['A'])
    trj = [pair['A'] for pair in read_trajectory_catrace(trj_file2)]
    start = time.time()
    aln_trj = align_trajectory(ref_pdb, trj[0], trj, ca_trace=True)
    end = time.time()
    print("Alignment time: %f" % (end - start))
    out_file = os.path.join(os.path.dirname(__file__), 'out',
                            'aligned_to_1a1v.pdb')
    with open(out_file, "w") as fh:
        for i, snapshot in enumerate(aln_trj):
            fh.write("MODEL %6d\n" % (i + 1))
            snapshot.write(fh)
            fh.write("ENDMDL\n")