[med-svn] [Git][med-team/epcr][master] Rename and improve functionality on fetch data

Saira Hussain gitlab at salsa.debian.org
Tue Jun 25 16:06:11 BST 2019



Saira Hussain pushed to branch master at Debian Med / epcr


Commits:
d5680fb6 by Saira Hussain at 2019-06-25T15:05:22Z
Rename and improve functionality on fetch data

Rename the file to be more clear on its function and add functions
that extend it in order to generate a primer file as expected.

- - - - -


1 changed file:

- + debian/tests/fetch_test_data.py


Changes:

=====================================
debian/tests/fetch_test_data.py
=====================================
@@ -0,0 +1,44 @@
+#!/usr/bin/python3
+# Fetching the required data for testing
+# a. entrez NCBI fasta test file
+# b. a primer data file
+from Bio import Entrez
+
+Entrez.email = 'unknown at debian.org'
+database = 'nucleotide'
+fn = 'data/gingo.fasta'
+
+query = [
+    '((chloroplast OR plastid) AND "complete genome" AND Embryophyta NOT (mi- tochondrion OR mitochondrial)) AND "Ginkgo biloba"'
+]
+
+primer = "rbcL1/rbcLA\t TTGGCAGCATTYCGAGTAACTCC\t CCTTTRTAACGATCAAGRC"
+
+
+def fetch_ids(dbs, qr):
+    # Fetch the query IDs
+    print(dbs, qr)
+    handle = Entrez.esearch(db=dbs, term=qr)
+    record = Entrez.read(handle)
+    ids = record['IdList']
+    handle.close()
+
+    # Fetch the first result
+    ff = open(fn, 'w')
+
+    handle_fasta = Entrez.efetch(
+        db=dbs, id=ids[0], rettype='fasta', retmode='text')
+    ff.write(handle_fasta.read().rstrip('\n'))
+
+    handle_fasta.close()
+
+
+def create_primer(pr):
+    pf = open('rbcL-primer.txt', 'w')
+    pf.write(pr)
+    pf.write('\n')
+    pf.close()
+
+
+fetch_ids(database, query)
+create_primer(primer)



View it on GitLab: https://salsa.debian.org/med-team/epcr/commit/d5680fb645bba60dd59ca5477b47eb3a917af9d0

-- 
View it on GitLab: https://salsa.debian.org/med-team/epcr/commit/d5680fb645bba60dd59ca5477b47eb3a917af9d0
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190625/f2d76ab9/attachment-0001.html>


More information about the debian-med-commit mailing list