Skip to content

Commit 5567f82

Browse files
authored
Chain type determination changed to _entity_poly.type (#8)
* Fixed chain type determination * Returned letter converters * Fixed entity id dictionary key
1 parent 5eddbcc commit 5567f82

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

rna3db/parser.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,10 @@ def __init__(
538538

539539
if molecule_type == "RNA":
540540
self.letters_3to1 = lambda x: modification_handler.rna_letters_3to1(x)
541+
self.polymer_type = "polyribonucleotide"
541542
elif molecule_type == "protein":
542543
self.letters_3to1 = lambda x: modification_handler.protein_letters_3to1(x)
544+
self.polymer_type = "polypeptide"
543545
else:
544546
raise ValueError('molecule_type must be one of "RNA" or "protein".')
545547

@@ -671,15 +673,19 @@ def chains(self):
671673
)
672674
)
673675

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
675686
chains = {}
676687
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]:
683689
chains[author_chain_id] = chain_data
684690

685691
# find starting index of relevant chains

0 commit comments

Comments
 (0)