def compute_mcss(self, ligands, init_file, mcss_types_file, small=False): """ Compute the MCSS file by calling Schrodinger canvasMCSS. Updates instance with MCSSs present in the file """ structure_file = '{}.ligands.mae'.format(init_file) mcss_file = '{}.mcss.csv'.format(init_file) stwr = StructureWriter(structure_file) stwr.append(ligands[self.l1]) stwr.append(ligands[self.l2]) stwr.close() # set the sizes in atoms of each of the ligands self._set_ligand_sizes(structure_file) if os.system( self.mcss_cmd.format(structure_file, mcss_file, 5 if small else 10, mcss_types_file)): assert False, 'MCSS computation failed' self._set_mcss(mcss_file) self.tried_small = small with open(init_file, 'a+') as fp: fp.write(str(self) + '\n') os.system('rm {} {}'.format(structure_file, mcss_file))
def save_merged_ligand_protein(self, raw_protein_file, raw_ligand_file): """ Merge structures from files and save to save directory :param raw_ligand_file: absolute paths :return: """ prot_st = next(StructureReader(raw_protein_file)) alpha = 'ABCDEFGHIJKMNOPQRST' alpha_count = 0 for c in prot_st.chain: if c.name.strip() == '': continue c.name = alpha[alpha_count] alpha_count += 1 if raw_ligand_file != '': lig_st = next(StructureReader(raw_ligand_file)) # standardize chain naming for c in lig_st.chain: c.name = 'L' merged_st = lig_st.merge(prot_st) else: merged_st = prot_st st_wr = StructureWriter(self.path + self.raw_complex) st_wr.append(merged_st) st_wr.close()
def split(self): #look for the opt_complex, if it doesn't exist, just use the prepped complex usefile = '' if (os.path.isfile(self.path + self.align_file)): usefile = self.path + self.align_file else: usefile = self.path + self.prepped_complex st = next(StructureReader(usefile)) prot_st = st.extract([a.index for a in st.atom if a.chain != 'L']) prot_st.title = '{}_prot'.format(self.name) lig_st = st.extract([a.index for a in st.atom if a.chain == 'L']) lig_st.title = '{}_lig'.format(self.name) prot_wr = StructureWriter(self.path + self.split_protein) prot_wr.append(prot_st) prot_wr.close() lig_wr = StructureWriter(self.path + self.split_ligand) lig_wr.append(lig_st) lig_wr.close()
""" The purpose of this code is to remove the ligands from a list of structure (.mae) files It can be run on sherlock using $ ml load chemistry $ ml load schrodinger $ $SCHRODINGER/run python3 ligand_remover.py """ import os from schrodinger.structure import StructureReader, StructureWriter if __name__ == '__main__': root = '/home/users/sidhikab/flexibility_project/mutations/Data/MAPK14/' files = sorted(os.listdir(root)) for s_file in files: if len(s_file) == 16: print(s_file) prot_path = s_file[:12] + '_nolig.mae' if os.path.exists(root + prot_path): print("Exists") else: st = next(StructureReader(root + s_file)) prot_st = st.extract( [a.index for a in st.atom if a.chain != 'L']) prot_wr = StructureWriter(root + prot_path) prot_wr.append(prot_st) prot_wr.close() os.remove(root + s_file)