Beispiel #1
0
    def one_file(self, pdbinfo):
        """
        updates self.data[besename of file_path] withe the pdb_info object
        on verbose print the data with more info  form the pdb itselef
        :param file_path:
        :param dir_path:
        :return:
        """
        _caller = self.__class__.__name__
        _pdb = pdbinfo._pdb
        _is_verbose = self.is_verbose
        if pdbinfo.output_type == 'json':
            self.is_verbose = False
        self.verbose('')
        self.verbose('+---------------------------------------------------')
        self.verbose('| {}'.format(os.path.basename(_pdb.file_name)))
        self.verbose('+---------------------------------------------------')
        self.is_verbose = _is_verbose
        try:
            if _pdb.has_caveats():
                self.cliutils.warn_msg("file:{} - has caveats lines!!!",
                                       caller=_caller)

            self.data[os.path.basename(_pdb.file_name)] = pdbinfo
            table_data = [["model No", "chain id", "residues", "atoms"]]
            for i, model in enumerate(_pdb, 1):

                # self.verbose("\t\tmodel No. {}:".format(model.model_number))
                for chain in model:
                    try:
                        table_data.append(
                            [model.model_number, None, None, None])
                        table_data[-1][1] = chain.chain_id
                        chaiutils = chain_utils(chain)
                        residues_list = chaiutils.chain2residues_list()
                        resnames_list = list(
                            map(lambda r: r.resname, residues_list))
                        # self.verbose("\t\t\tchains info:{:>2}  number of residues: {}".format(chain.chain_id,
                        #                                                                       len(resnames_list)))
                        table_data[-1][2] = len(resnames_list)
                        table_data[-1][3] = len(chain)
                    except Exception as e:
                        msg = "file:{} - model {} - chain {} - {}"
                        self.cliutils.error_msg(msg.format(
                            _pdb.file_name, model.model_number, chain.chain_id,
                            e),
                                                caller=_caller)
                        self.errors[_pdb.file_name] = e

            self.verbose(pdbinfo.info_report(models_table_data=table_data))
        except Exception as e:
            self.cliutils.error_msg("file:{} - {}".format(_pdb.file_name, e),
                                    caller=_caller)
            self.errors[_pdb.file_name] = e
        return 1
Beispiel #2
0
 def remove_atoms_from_every_chain(cls, atoms_to_remove, _pdb):
     """
     TODO documentation
     :param atoms_to_remove: [(resname, resseq,atom_name)]
     :param _pdb:
     :return:
     """
     for mi, model in enumerate(_pdb):
         for ci, chain in enumerate(model):
             chainuils = chain_utils(chain)
             _pdb[mi][ci] = chainuils.remove_atoms_by_atom_resseq_and_name(atoms_to_remove)
     return _pdb
Beispiel #3
0
    def remove_residues_from_every_chain(cls, missing_residues_per_chain_id, _pdb):
        """
        TODO documentation
        :param missing_residues_per_chain_id:
        :param _pdb:
        :return:
        """
        missing_residues = []
        for chain_id, mis_res_list in missing_residues_per_chain_id.items():
            missing_residues.extend(mis_res_list)

        for mi, model in enumerate(_pdb):
            for ci, chain in enumerate(model):
                chainuils = chain_utils(chain)
                _pdb[mi][ci] = chainuils.remove_residues_by_resseqs(missing_residues)
        return _pdb
Beispiel #4
0
 def sieve(self, pdb, fix_atoms_serial_number=False):
     _pdb = pdb
     atoms_to_remove = []
     for mi, model in enumerate(_pdb):
         for ci, chain in enumerate(model):
             for ai, atom in enumerate(chain):
                 for prefix_name in self.atom_names:
                     if self.is_match(atom, prefix_name):
                         atoms_to_remove.append(ai)
             for ai in reversed(atoms_to_remove):
                 del _pdb[mi][ci][ai]
             atoms_to_remove = []
             if fix_atoms_serial_number:
                 chinnutils = chain_utils(chain)
                 chinnutils.fix_atoms_serial_number()
                 _pdb[mi][ci] = chinnutils.chain
     return _pdb
Beispiel #5
0
 def __init__(self, chain_a, chain_b):
     self.residues_list_a = chain_utils(chain_a).chain2residues_list()
     self.residues_list_b = chain_utils(chain_b).chain2residues_list()
     self.df = None