def get_chain_details_by_related_pdb_chains(self, pdb_id, chain_id, pfam_accs):
        ''' Returns a dict of SCOPe details using info
            This returns Pfam-level information for a PDB chain i.e. no details on the protein, species, or domain will be returned.
            If there are SCOPe entries for the associated Pfam accession numbers which agree then this function returns
            pretty complete information.
        '''

        if not pfam_accs:
            return None

        associated_pdb_chains = set()
        pfam_api = self.get_pfam_api()
        for pfam_acc in pfam_accs:
            associated_pdb_chains = associated_pdb_chains.union(pfam_api.get_pdb_chains_from_pfam_accession_number(pfam_acc))

        hits = []
        #class_count = {}

        pfam_scop_mapping = {}
        for pdb_chain_pair in associated_pdb_chains:
            ass_pdb_id, ass_chain_id = pdb_chain_pair[0], pdb_chain_pair[1]
            hit = self.get_chain_details(ass_pdb_id, chain = ass_chain_id, internal_function_call = True, pfam_scop_mapping = pfam_scop_mapping)
            if hit and hit.get('chains'):
                assert(len(hit['chains']) == 1)
                hits.append(hit['chains'][ass_chain_id])
                #for k, v in hit.iteritems():
                    #class_count[v['sccs']] = class_count.get(v['sccs'], 0)
                    #class_count[v['sccs']] += 1
                    #print(' %s, %s: %s' % (v['pdb_id'], k, v['sccs']))
        #pprint.pprint(class_count)
        allowed_scop_domains = map(int, map(set.intersection, pfam_scop_mapping.values())[0])
        allowed_scop_domains = list(set((allowed_scop_domains or []) + (self.get_sunid_for_pfam_accs(pfam_accs) or [])))


        filtered_hits = []
        print(pfam_accs)
        print(allowed_scop_domains)
        print('%d hits' % len(hits))
        for hit in hits:
            domains_to_ignore = []
            for k, v in hit['domains'].iteritems():
                if v['sunid'] in allowed_scop_domains:
                    filtered_hits.append(v)
        print('%d filtered_hits' % len(filtered_hits))

        if not filtered_hits:
            return None

        d = self.get_basic_pdb_chain_information(pdb_id, chain_id)
        d.update(self.get_common_fields(filtered_hits))
        d.update(dict(
            SCOPe_sources = 'Pfam + SCOPe',
            SCOPe_search_fields = 'Pfam + link_pdb.pdb_chain_id',
            SCOPe_trust_level = 3
        ))
        # Add the lowest common classification over all related Pfam families
        for k, v in sorted(self.levels.iteritems()):
            d[v] = None
        d.update(dict(self.get_common_hierarchy(filtered_hits)))
        return d
def get_chain_details_by_related_pdb_chains ( self , pdb_id , chain_id , pfam_accs ) : if not pfam_accs : return None associated_pdb_chains = set ( ) pfam_api = self . get_pfam_api ( ) for pfam_acc in pfam_accs : associated_pdb_chains = associated_pdb_chains . union ( pfam_api . get_pdb_chains_from_pfam_accession_number ( pfam_acc ) ) hits = [ ] pfam_scop_mapping = { } for pdb_chain_pair in associated_pdb_chains : ass_pdb_id , ass_chain_id = pdb_chain_pair [ 0 ] , pdb_chain_pair [ 1 ] hit = self . get_chain_details ( ass_pdb_id , chain = ass_chain_id , internal_function_call = True , pfam_scop_mapping = pfam_scop_mapping ) if hit and hit . get ( 'chains' ) : assert ( len ( hit [ 'chains' ] ) == 1 ) hits . append ( hit [ 'chains' ] [ ass_chain_id ] ) allowed_scop_domains = map ( int , map ( set . intersection , pfam_scop_mapping . values ( ) ) [ 0 ] ) allowed_scop_domains = list ( set ( ( allowed_scop_domains or [ ] ) + ( self . get_sunid_for_pfam_accs ( pfam_accs ) or [ ] ) ) ) filtered_hits = [ ] print ( pfam_accs ) print ( allowed_scop_domains ) print ( '%d hits' % len ( hits ) ) for hit in hits : domains_to_ignore = [ ] for k , v in hit [ 'domains' ] . iteritems ( ) : if v [ 'sunid' ] in allowed_scop_domains : filtered_hits . append ( v ) print ( '%d filtered_hits' % len ( filtered_hits ) ) if not filtered_hits : return None d = self . get_basic_pdb_chain_information ( pdb_id , chain_id ) d . update ( self . get_common_fields ( filtered_hits ) ) d . update ( dict ( SCOPe_sources = 'Pfam + SCOPe' , SCOPe_search_fields = 'Pfam + link_pdb.pdb_chain_id' , SCOPe_trust_level = 3 ) ) for k , v in sorted ( self . levels . iteritems ( ) ) : d [ v ] = None d . update ( dict ( self . get_common_hierarchy ( filtered_hits ) ) ) return d
Returns a dict of SCOPe details using info
            This returns Pfam-level information for a PDB chain i.e. no details on the protein, species, or domain will be returned.
            If there are SCOPe entries for the associated Pfam accession numbers which agree then this function returns
            pretty complete information.