@@ -538,8 +538,10 @@ def __init__(
538
538
539
539
if molecule_type == "RNA" :
540
540
self .letters_3to1 = lambda x : modification_handler .rna_letters_3to1 (x )
541
+ self .polymer_type = "polyribonucleotide"
541
542
elif molecule_type == "protein" :
542
543
self .letters_3to1 = lambda x : modification_handler .protein_letters_3to1 (x )
544
+ self .polymer_type = "polypeptide"
543
545
else :
544
546
raise ValueError ('molecule_type must be one of "RNA" or "protein".' )
545
547
@@ -671,15 +673,19 @@ def chains(self):
671
673
)
672
674
)
673
675
674
- # keep only chains that contain at least one 'self.molecule_type'
676
+ # Get chain/polymer types
677
+ chain_type = {}
678
+ for entity_id , poly_type in zip (
679
+ self .parsed_info ["_entity_poly.entity_id" ],
680
+ self .parsed_info ["_entity_poly.type" ],
681
+ ):
682
+ for author_id in id_map [entity_id ]:
683
+ chain_type [author_id ] = poly_type
684
+
685
+ # keep only chains of the appropriate polymer type
675
686
chains = {}
676
687
for author_chain_id , chain_data in chains_full .items ():
677
- if any (
678
- [
679
- self .molecule_type in chem_comp_type [i .three_letter_code ]
680
- for i in chain_data .residues
681
- ]
682
- ):
688
+ if self .polymer_type in chain_type [author_chain_id ]:
683
689
chains [author_chain_id ] = chain_data
684
690
685
691
# find starting index of relevant chains
0 commit comments