Skip to content

Commit

Permalink
Now handles 503 coming from UniProt
Browse files Browse the repository at this point in the history
No idea why they were happening
Updated actions to V4
  • Loading branch information
iquasere committed Oct 1, 2024
1 parent 2143998 commit 5e492af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
tags: upimapi:latest
outputs: type=docker,dest=/tmp/upimapi.tar
- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: upimapi
path: /tmp/upimapi.tar
Expand All @@ -32,7 +32,7 @@ jobs:
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upimapi
path: /tmp
Expand All @@ -46,7 +46,7 @@ jobs:
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upimapi
path: /tmp
Expand All @@ -60,7 +60,7 @@ jobs:
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upimapi
path: /tmp
Expand All @@ -74,7 +74,7 @@ jobs:
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upimapi
path: /tmp
Expand All @@ -88,7 +88,7 @@ jobs:
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upimapi
path: /tmp
Expand All @@ -102,7 +102,7 @@ jobs:
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upimapi
path: /tmp
Expand Down
12 changes: 6 additions & 6 deletions upimapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from functools import partial
import re

__version__ = '1.13.1'
__version__ = '1.13.2'


def load_api_info():
Expand Down Expand Up @@ -195,7 +195,7 @@ def get_arguments():


def timed_message(message):
print(f'{strftime("%Y-%m-%d %H:%M:%S", gmtime())}: {message}')
print(f'[{strftime("%Y-%m-%d %H:%M:%S", gmtime())}] {message}')


def human_time(seconds):
Expand Down Expand Up @@ -275,7 +275,7 @@ def uniprot_request(ids, columns=None, output_format='tsv'):
return resp.text


def split(a, n):
def split_list(a, n):
k, m = divmod(len(a), n)
return (a[i * k + min(i, m):(i + 1) * k + min(i + 1, m)] for i in range(n))

Expand Down Expand Up @@ -347,7 +347,7 @@ def basic_idmapping_batch(ids, from_db, to_db, step=1000):

def basic_idmapping_multiprocess(ids, output, from_db, to_db, step=1000, threads=15):
result = pd.DataFrame()
ids_groups = split(ids, threads)
ids_groups = split_list(ids, threads)
with Manager() as m:
with m.Pool() as p:
mapping_results = p.starmap(basic_idmapping_batch, [(
Expand Down Expand Up @@ -392,7 +392,7 @@ def get_valid_entries_batch(ids, step=1000):

def get_valid_entries_multiprocess(ids, step=1000, threads=15):
valid_entries = []
ids_groups = split(ids, threads)
ids_groups = split_list(ids, threads)
with Manager() as m:
with m.Pool() as p:
result = p.starmap(get_valid_entries_batch, [(ids_group, step) for ids_group in ids_groups])
Expand Down Expand Up @@ -923,7 +923,7 @@ def get_upper_taxids(taxid, tax_df):
def parse_taxonomy(data, tax_tsv_df, threads=15):
tax_tsv_df.set_index('name', inplace=True)
tax_tsv_df['taxid'] = tax_tsv_df['taxid'].astype(str)
all_classifications = split(data['organism_classification'].drop_duplicates().tolist(), threads)
all_classifications = split_list(data['organism_classification'].drop_duplicates().tolist(), threads)
with Manager() as m:
with m.Pool() as p:
result = p.starmap(lineages_to_columns, [(classifications, tax_tsv_df)
Expand Down

0 comments on commit 5e492af

Please sign in to comment.