How to use retrieve_references method in avocado

Best Python code snippet using avocado_python

build_db.py

Source:build_db.py Github

copy

Full Screen

...29 else:30 seq.append(line.strip())31 if seq:32 yield header, ''.join(seq)33def retrieve_references(pubmed_ids):34 resp = requests.post(35 ESUMMARY_URL,36 data={37 'db': 'pubmed',38 'id': ','.join(pubmed_ids),39 'retmode': 'json'40 }41 )42 data = resp.json()43 references = OrderedDict()44 for uid in sorted(data['result']['uids']):45 ref = data['result'][uid]46 references[uid] = OrderedDict({47 'MedlineID': uid,48 'PubYear': ref.get('pubdate', '').split(' ')[0],49 'firstAuthor': ref['authors'][0]['name'],50 'Title': ref['title'],51 'Journal': ref['source']52 })53 return references54def list_subtypes(seqs):55 subtypes = set()56 for seq in seqs:57 subtypes.add(seq['Subtype'])58 return sorted(subtypes)59def list_sources(seqs):60 sources = set()61 for seq in seqs:62 sources.add(seq['Source'])63 return sorted(sources)64def main():65 facttable, fasta, sierra_report, outputdir = sys.argv[1:]66 with open(facttable) as fp1, open(sierra_report) as fp2:67 if fp1.read(1) != '\ufeff':68 fp1.seek(0)69 sequences = list(csv.DictReader(fp1))70 sequence_reports = json.load(fp2)71 sequence_reports = {72 sr['inputSequence']['header'].split('.', 1)[0]: sr73 for sr in sequence_reports74 }75 result_sequences = []76 pubmed_ids = set()77 min_days_offsets = {}78 for seq in sequences:79 pt = seq['PtIdentifier']80 offset = \81 datetime.strptime(seq['CollectionDate'], '%Y-%m-%d') - DATE_190082 offset = offset.days83 min_days_offsets[pt] = \84 min(min_days_offsets.get(pt, 0xffffffff), offset)85 for seq in sequences:86 pt = seq['PtIdentifier']87 offset = \88 datetime.strptime(seq['CollectionDate'], '%Y-%m-%d') - DATE_190089 offset = offset.days90 weeks = int('{:.0f}'.format((offset - min_days_offsets[pt]) / 7))91 seq = OrderedDict(seq)92 pubmed_ids.add(seq['MedlineID'])93 accs = seq['Accession']94 seqreport = sequence_reports[accs]95 subtype = seqreport['subtypeText'].split(' (', 1)[0]96 seq.update({97 'Weeks': weeks,98 'PR': 0,99 'RT': 0,100 'IN': 0,101 'NumPRMixtures': None,102 'NumPRMutations': None,103 'NumRTMixtures': None,104 'NumRTMutations': None,105 'NumINMixtures': None,106 'NumINMutations': None,107 'NumPRNAAmbiguities': None,108 'NumRTNAAmbiguities': None,109 'NumINNAAmbiguities': None,110 'Subtype': subtype,111 })112 for gene_seq in seqreport['alignedGeneSequences']:113 gene = gene_seq['gene']['name']114 seq['Num{}Mixtures'.format(gene)] = len([115 m for m in gene_seq['mutations']116 if PATTERN_MIXTURES.match(m['AAs'])])117 seq['Num{}Mutations'.format(gene)] = len(gene_seq['mutations'])118 seq[gene] = 1119 seq['Num{}NAAmbiguities'.format(gene)] = len([120 n for n in gene_seq['alignedNAs'].upper()121 if n in 'WSMKRYBDHVN'])122 result_sequences.append(seq)123 result_data = OrderedDict({124 'sequences': result_sequences,125 'references': retrieve_references(pubmed_ids),126 'subtypes': list_subtypes(result_sequences),127 'sources': list_sources(result_sequences),128 })129 factjson = os.path.join(outputdir, 'meta.json')130 with open(factjson, 'w') as outfp:131 json.dump(result_data, outfp)132 # We don't need this anymore133 # for header, seq in fasta_reader(fasta):134 # accs = header.split('.', 1)[0]135 # single = os.path.join(outputdir, 'sequences', '{}.json'.format(accs))136 # with open(single, 'w') as outfas:137 # json.dump({'header': header, 'sequence': seq}, outfas)138if __name__ == '__main__':139 main()

Full Screen

Full Screen

retrieve_biblio.py

Source:retrieve_biblio.py Github

copy

Full Screen

...8def create_arxiv_url(result: str) -> str:9 if ARXIV_VERSION.match(result, len(result) - 2):10 result = result[:-2]11 return BASE_URL + result12def retrieve_references(search_result: u.SearchResult) -> List[str]:13 response = r.get(create_arxiv_url(search_result.id))14 if response.ok:15 references = j.loads(response.content)['references']16 return [reference['arxivId'] for reference in references if reference['arxivId']]17 else:18 response.raise_for_status()19if __name__ == '__main__':...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

12from .main import citation_to_paper_info34#from .main import paper_info_from_citation5#from .main import paper_info_from_link6#from .main import doi_and_title_from_citation7#from .main import doi_to_webscraped_info8#from .main import retrieve_all_info9#from .main import retrieve_only_references1011#from .ref_retrieval import retrieve_references ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful