Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generation of dict_proteinId_assemblyIds for Entrez download #3

Merged
merged 5 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Initial release of nf-core/metapep, created with the [nf-core](https://nf-co.re/

- [#41](https://github.com/skrakau/metapep/pull/41) - Allow `assembly` input without weights
- [#53](https://github.com/skrakau/metapep/pull/53) - Add buffering of predictions and chunk-wise merging to avoid sbatch error due to too many input files [#52](https://github.com/skrakau/metapep/issues/52)
- [#3](https://github.com/nf-core/metapep/pull/3) - Fix generation of `entities_proteins.entrez.tsv` for Entrez download

### `Dependencies`

Expand Down
9 changes: 2 additions & 7 deletions bin/download_proteins_entrez.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,13 @@ def main(args=None):
sys.exit("Entrez elink download failed!")

### for each nucleotide sequence get list of protein ids
dict_proteinId_assemblyIds = {}
dict_proteinId_assemblyIds = defaultdict(lambda : set())
for nucleotide_record in protein_results:
seqId = nucleotide_record["IdList"][0]
assemblyIds = dict_seqId_assemblyIds[seqId]
if len(nucleotide_record["LinkSetDb"]) > 0:
for protein_record in nucleotide_record["LinkSetDb"][0]["Link"]:
if protein_record["Id"] not in dict_proteinId_assemblyIds:
dict_proteinId_assemblyIds[protein_record["Id"]] = assemblyIds
else:
for i in assemblyIds:
if i not in dict_proteinId_assemblyIds[protein_record["Id"]]:
dict_proteinId_assemblyIds[protein_record["Id"]].append(i)
dict_proteinId_assemblyIds[protein_record["Id"]].update(assemblyIds)

# NOTE:
# some proteins, such as 487413233, occur within multiple sequences of the assembly!
Expand Down