Exemple #1
0
 def load_struct(self, args, struct_var, mirror_var, strip_water, strip_hydrogen):
     struct_id = getattr(args, struct_var)
     if getattr(args, mirror_var) is not None:
         mirror_path = getattr(args, mirror_var)
         struct = load_cif_from_mirror(struct_id, mirror_path)
     else:
         struct = load_cif_from_file(struct_id)
     if strip_water:
         for model in struct:
             preprocess.strip_water(model)
     if strip_hydrogen:
         for model in struct:
             preprocess.strip_hydrogen(model)
     setattr(args, struct_var, struct)
                (i1, i2) for i1 in lst1 for i2 in lst2
                if id(i1) != id(i2) and  #not the same object
                self._dist(i1[0], i2[0])
            ]

        return (pair
                for xi in range(self.min_coords[0], self.max_coords[0] + 1)
                for xj in range(self.min_coords[1], self.max_coords[1] + 1)
                for xk in range(self.min_coords[1], self.max_coords[1] + 1)
                for di in range(0, 2) for dj in range(0, 2)
                for dk in range(0, 2) for pair in _all_neighbors(
                    self.coord_sparse_mat.get((xi, xj, xk), []),
                    self.coord_sparse_mat.get((xi + di, xj + dj,
                                               xk + dk), [])))


if __name__ == '__main__':
    import sys
    from mmstructlib.IO import load_cif_from_mirror
    if len(sys.argv) != 2:
        exit("usage: {} <struct id>".format(sys.argv[0]))

    struct = load_cif_from_mirror(sys.argv[1])

    gridhash = GridHash([(a.coordinates, a) for a in struct[0].atoms], 10)
    for (ac1, a1), (ac2, a2) in gridhash.all_neighbors_iter():
        print("{}.{}/{}/{}-{}.{}/{}/{}".format(a1.molecule.id, a1.monomer.id,
                                               a1.monomer.type, a1.name,
                                               a2.molecule.id, a2.monomer.id,
                                               a2.monomer.type, a2.name))
    print("\n".join([
        "options:",
        "	-c <chains>    limit return to these chains (comma seperated)",
        "	-f             interpret <struct> as file name",
        "	-m             set pdb mirror directory, default: {0}".format(mirror)
    ]))
    sys.exit(1)

chains = optdict.get('-c', None)
if chains:
    chains = chains.split(",")
mirror = optdict.get('-m', mirror)

if '-f' in optdict:
    loader = load_cif_from_file
else:
    loader = lambda x: load_cif_from_mirror(x, mirror)

struct = loader(args[0])
chains = [
    m for m in struct[0].molecules
    if m.is_protein() and (not chains or m.pdb_id in chains)
]

for chain in chains:
    seq = [
        c321(s) if a is not None else c321(s).lower() for s, a in chain.seq_res
    ]
    print(">{0}_{1}".format(struct.id, chain.pdb_id))
    print("".join(seq))