Skip to content

Commit

Permalink
Update 2022.11.29 little change
Browse files Browse the repository at this point in the history
1. add utility.get_result_from_file()
2. fixed some bugs
  • Loading branch information
henry-leo committed Nov 29, 2022
1 parent e6354c0 commit 66df1ea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions patpat/querier.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def get_properties(self):

return self.digestion_params, self.source, self.filtered_peptides

def query(self):
def query(self, threshold=1):
"""Functions for external calls. 供外部调用的函数。
Raises:
Expand All @@ -386,7 +386,7 @@ def query(self):
raise ValueError('Please run func self.set_params() first. 请先运行self.set_params()函数')

self.digestion()
self.search()
self.search(threshold=1)


class UniProtPeptideQuerier(PeptideQuerier):
Expand Down
24 changes: 23 additions & 1 deletion patpat/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import re
import time
import json
import gzip
from urllib import parse
from ftplib import FTP
Expand Down Expand Up @@ -162,7 +163,7 @@ def pagination_download_uniprot_proteome(identifier: str, reviewed: bool = True,
total = int(response.headers['x-total-results'])
fasta = [response.text]

for i in tqdm.tqdm(range(size, total, size)):
for _ in tqdm.tqdm(range(size, total, size)):
try:
response = session.get(response.links['next']['url'])
fasta.extend([response.text])
Expand Down Expand Up @@ -266,3 +267,24 @@ def inner():
return _instance[cls]

return inner


def get_result_from_file(task=None):
"""Get Patpat search result from patpat_env/result/<task>/result.json
Args:
task: uuid
Returns:
dict, project metadata
"""
if task:
with open(f'patpat_env/result/{task}/result.json') as f:
data_json = ''.join(f.readlines())
data_dict = json.loads(data_json)
f.close()

return data_dict

else:
print('Need to input task uuid.')

0 comments on commit 66df1ea

Please sign in to comment.