Exemplo n.º 1
0
 def check_msms(self, prot_file, first_100_residues):
     p = PDBParser()
     with warnings.catch_warnings():
         warnings.simplefilter("ignore", PDBConstructionWarning)
         s = p.get_structure("X", prot_file)
     model = s[0]
     rd = ResidueDepth(model)
     res_chain = ""
     for item in rd.property_list[:100]:
         res_chain = res_chain + item[0].get_resname()
     self.assertEqual(res_chain, first_100_residues)
    def check_msms(self, prot_file, first_100_residues):
        """Wrap calls to MSMS and the respective tests."""
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", PDBConstructionWarning)
            s = self.pdbparser.get_structure("X", prot_file)

        model = s[0]
        rd = ResidueDepth(model)
        residues = []
        for item in rd.property_list[:100]:
            residues.append(item[0].get_resname())
        self.assertEqual("".join(residues), first_100_residues)
    def extract_feature(self):
        print_info_nn(" >>> Adding residue depth for database {0} ... ".format(self._database.name))
        overall_time = datetime.now()
        counter = 0
        if not os.path.exists(self._get_dir_name()):
            os.makedirs(self._get_dir_name())
        for complex_name in self._database.complexes.keys():
            protein_complex = self._database.complexes[complex_name]
            proteins = [protein_complex.unbound_formation.ligand, protein_complex.unbound_formation.receptor]
            for protein in proteins:
                residue_depth_file = self._get_dir_name() + protein.name + ".npy"
                if not os.path.exists(residue_depth_file):
                    counter += 1
                    if counter <= 15:
                        print_info_nn("{0}, ".format(protein.name))
                    else:
                        counter = 0
                        print_info("{0}".format(protein.name))

                    pdb_file = self._database.directory + pdb_directory + protein.name + ".pdb"
                    rd = ResidueDepth(protein.structure[0], pdb_file)
                    rd_array = np.ndarray((len(protein.residues), 2))  # self.number_of_bins +
                    # surface = get_surface(pdb_file)
                    for (i, res) in enumerate(protein.biopython_residues):
                        (_, _, c, (h, rn, ic)) = res.get_full_id()
                        key = (c, (h, rn, ic))
                        if key in rd:
                            rdv = rd[key]
                            if rdv[0] is None:
                                rdv = (0, rdv[1])
                                print "WTH?"
                            if rdv[1] is None:
                                rdv = (rdv[0], 0)
                                print "WTH?"
                            rd_array[i, :2] = rdv
                        else:
                            print_error('WTH')
                            rd_array[i, :2] = [0, 0]
                            # rd_array[i, 2:] = self._compute_distribution_(surface, protein.residues[i].center)

                    np.save(residue_depth_file, rd_array)
                surface_features = np.load(residue_depth_file)
                for i, res in enumerate(protein.residues):
                    res.add_feature(Features.RESIDUE_DEPTH, self._normalize(surface_features[i, :2]))
        print_info("took {0} seconds.".format((datetime.now() - overall_time).seconds))
Exemplo n.º 4
0
    print("ERROR: Cannot open output file!")

parser = PDBParser(PERMISSIVE=1)
try:
    pdb_path = sys.argv[1]
    st = parser.get_structure('st', pdb_path)
except OSError:
    print("ERROR: We cannot load the PDB! Did you provide a proper path?")
    sys.exit(2)

if len(st) > 1:  # Checking for models
    print("WARNING: Several Models found, using only first")

# Using Model 0 any way and the first chain
st = st[0]
st = tuple(st.get_chains())[0]  # In case there is more than one line

residueID__depth = {}
resdepth = ResidueDepth(st)
for resInfo, depth in resdepth:
    residueID__depth[(resInfo.get_resname(),
                      resInfo.get_full_id()[-1][1])] = depth[0]

print("aa", "pos", "surface", file=outFile, sep="\t")
for k in residueID__depth:
    if residueID__depth[k] < distanceSurface:
        print(k[0], k[1], 1, file=outFile, sep="\t")
    else:
        print(k[0], k[1], 0, file=outFile, sep="\t")
outFile.close()
Exemplo n.º 5
0
elif args.exp == "CN":
    hse = ExposureCN(m, RADIUS)
    k = "EXP_CN"
elif args.exp == "ANGLE":
    hse = HSExposureCA(m, RADIUS)
    k = "EXP_CB_PCB_ANGLE"
    format = "%4.1f"
elif args.exp == "DSSPR":
    d = DSSP(m, args.pdbfile, dssp=args.dssp)
    k = "EXP_DSSP_RASA"
    format = "%.4f"
elif args.exp == "DSSPA":
    d = DSSP(m, args.pdbfile, dssp=args.dssp)
    k = "EXP_DSSP_ASA"
elif args.exp == "RD":
    d = ResidueDepth(m, args.pdbfile, msms_exec=args.msms)
    k = "EXP_RD"
    format = "%4.1f"
elif args.exp == "RDA":
    d = ResidueDepth(m, args.pdbfile, msms_exec=args.msms)
    k = "EXP_RD_CA"
    format = "%4.1f"
else:
    print("ERROR: Unknown option.")
    sys.exit()

residue_list = Selection.unfold_entities(m, "R")

for r in residue_list:

    if k in r.xtra: