Skip to content

Commit

Permalink
Chain type determination changed to _entity_poly.type (#8)
Browse files Browse the repository at this point in the history
* Fixed chain type determination

* Returned letter converters

* Fixed entity id dictionary key
  • Loading branch information
RJPenic authored Oct 4, 2024
1 parent 5eddbcc commit 5567f82
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions rna3db/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,10 @@ def __init__(

if molecule_type == "RNA":
self.letters_3to1 = lambda x: modification_handler.rna_letters_3to1(x)
self.polymer_type = "polyribonucleotide"
elif molecule_type == "protein":
self.letters_3to1 = lambda x: modification_handler.protein_letters_3to1(x)
self.polymer_type = "polypeptide"
else:
raise ValueError('molecule_type must be one of "RNA" or "protein".')

Expand Down Expand Up @@ -671,15 +673,19 @@ def chains(self):
)
)

# keep only chains that contain at least one 'self.molecule_type'
# Get chain/polymer types
chain_type = {}
for entity_id, poly_type in zip(
self.parsed_info["_entity_poly.entity_id"],
self.parsed_info["_entity_poly.type"],
):
for author_id in id_map[entity_id]:
chain_type[author_id] = poly_type

# keep only chains of the appropriate polymer type
chains = {}
for author_chain_id, chain_data in chains_full.items():
if any(
[
self.molecule_type in chem_comp_type[i.three_letter_code]
for i in chain_data.residues
]
):
if self.polymer_type in chain_type[author_chain_id]:
chains[author_chain_id] = chain_data

# find starting index of relevant chains
Expand Down

0 comments on commit 5567f82

Please sign in to comment.