def structure_to_complex(structure: Structure): residues = {} chains = {} for pqr_atom in structure.atoms: atom = _Atom._create() atom._symbol = pqr_atom.atom_name[:1] atom._serial = pqr_atom.atom_number atom._name = pqr_atom.atom_name atom._position = pqr_atom.position atom._is_het = pqr_atom.is_het if not pqr_atom.chain_id in chains: chain = _Chain._create() chain._name = pqr_atom.chain_id chains[pqr_atom.chain_id] = chain if not pqr_atom.residue_number in residues: residue = _Residue._create() residue._name = pqr_atom.residue_name residue._type = pqr_atom.residue_name residue._serial = pqr_atom.residue_number residues[pqr_atom.residue_number] = residue chains[pqr_atom.chain_id]._add_residue(residue) residues[pqr_atom.residue_number]._add_atom(atom) mol = _Molecule._create() for chain in chains: mol._add_chain(chains[chain]) complex = _Complex._create() complex._add_molecule(mol) return complex._convert_to_conformers()
def structure(content): # type: (Content) -> Complex complex = _Complex._create() for model in content.models: complex._add_molecule(structure_molecule(model)) complex._remarks = {} return complex._convert_to_conformers()
def __next(self): # Go to next molecule complex = self.__complexes[self.__complex_idx] framed_complex = self.__framed_complexes[self.__complex_idx] self.__molecule_idx += 1 if self.__molecule_idx >= len(framed_complex._molecules): self.__complex_idx += 1 if self.__complex_idx >= len(self.__complexes): self.__done() return complex = self.__complexes[self.__complex_idx] framed_complex = self.__framed_complexes[self.__complex_idx] self.__molecule_idx = 0 self.__saved_complex = complex self.__saved_is_conformer = len(complex._molecules) == 1 molecule = framed_complex._molecules[self.__molecule_idx] single_frame = _Complex._create() single_frame._add_molecule(molecule) _pdb.to_file(self.__input.name, single_frame) self.__proc.start()
def structure(content): num_molecules = max(content.model_count, 1) atoms_by_molecule = [] for i in range(num_molecules): atoms_by_molecule.append([]) for ratom in content.atoms: atoms_by_molecule[ratom.model_number - 1].append(ratom) complex = _Complex._create() complex._remarks = content._remarks for i in range(num_molecules): molecule = structure_molecule(atoms_by_molecule[i], content.compnds) molecule._name = str(i) complex._add_molecule(molecule) # Done return complex._convert_to_conformers()
def structure(content): remarks = StructureRemarks(content.remarks) complex = _Complex._create() complex._remarks = remarks # All structured infos all_atoms = {} all_residues = {} all_chains = {} all_molecules = {} helper = None if content.cell != None: helper = UnitCellHelper(content.cell) # Read all atoms for c_atom in content.atoms: chain_name = c_atom.chain if c_atom.is_het: chain_name = "H" + chain_name molecule_id = str(c_atom.model) chain_id = molecule_id + ":" + chain_name residue_id = chain_id + ":" + str(c_atom.residue_serial) atom_id = residue_id + ":" + str(c_atom.atom_serial) if not atom_id in all_atoms: if not residue_id in all_residues: if not chain_id in all_chains: if not molecule_id in all_molecules: molecule = _Molecule._create() molecule._name = str(c_atom.model) all_molecules[molecule_id] = molecule complex._add_molecule(molecule) chain = _Chain._create() chain._name = chain_name all_chains[chain_id] = chain all_molecules[molecule_id]._add_chain(chain) residue = _Residue._create() residue._name = c_atom.residue_name residue._type = residue._name residue.serial = c_atom.residue_serial all_residues[residue_id] = residue all_chains[chain_id]._add_residue(residue) atom = StructureAtom(c_atom, helper) all_atoms[atom_id] = None all_residues[residue_id]._add_atom(atom) # Done return complex._convert_to_conformers()
def __next(self): # Go to next molecule complex = self.__complexes[self.__complex_idx] framed_complex = self.__framed_complexes[self.__complex_idx] self.__molecule_idx += 1 # first frame if conformer, all frames if in frames (may change) if self.__molecule_idx >= len(complex._molecules): self.__update_secondary_structure(complex) self.__current_complex_result.clear() self.__complex_idx += 1 if self.__complex_idx >= len(self.__complexes): self.__done() return complex = self.__complexes[self.__complex_idx] framed_complex = self.__framed_complexes[self.__complex_idx] self.__molecule_idx = 0 molecule = framed_complex._molecules[self.__molecule_idx] single_frame = _Complex._create() single_frame._add_molecule(molecule) _pdb.to_file(self.__input.name, single_frame) self.__proc.start()