2

I was trying to create a database from NCBI Nucleotide bank. I did a query which gave me 1124 results. From each single result I was wanting to obtain only the items realted to Accesion Country and isolation.

Here is what I get from the NCBI

LOCUS MH973850 410 bp DNA linear PLN 03-MAR-2019 DEFINITION Cryptococcus neoformans isolate OA2 internal transcribed spacer 1, partial sequence; 5.8S ribosomal RNA gene, complete sequence; and internal transcribed spacer 2, partial sequence. ACCESSION MH973850 VERSION MH973850.1 KEYWORDS . SOURCE Cryptococcus neoformans ORGANISM Cryptococcus neoformans Eukaryota; Fungi; Dikarya; Basidiomycota; Agaricomycotina; Tremellomycetes; Tremellales; Cryptococcaceae; Cryptococcus; Cryptococcus neoformans species complex. REFERENCE 1 (bases 1 to 410) AUTHORS Abaci Gunyar,O., Yoltas,A., Haliki Uztan,A. and Yamac,M. TITLE Isolation and Identification of Cryptococcus neoformans from the soil samples taken from inside and outside of Nigde Duzkir (= Aladaglar) cave JOURNAL Unpublished REFERENCE 2 (bases 1 to 410) AUTHORS Abaci Gunyar,O., Yoltas,A., Haliki Uztan,A. and Yamac,M. TITLE Direct Submission JOURNAL Submitted (24-SEP-2018) Biology, Ege University, Genclik Caddesi, Izmir 35040, Turkiye COMMENT ##Assembly-Data-START## Sequencing Technology :: Sanger dideoxy sequencing ##Assembly-Data-END## FEATURES Location/Qualifiers source 1..410 /organism="Cryptococcus neoformans" /mol_type="genomic DNA" /isolate="OA2" /isolation_source="Soil sample" /db_xref="taxon:5207" misc_RNA <1..>410 /note="contains internal transcribed spacer 1, 5.8S ribosomal RNA, and internal transcribed spacer 2" ORIGIN
1 aggatcagta gagaatattg gacttcggtc catttatcta cccatctaca cctgtgaact 61 gtttatgtgc ttcggcacgt tttacacaaa cttctaaatg taatgaatgt aatcttatta 121 taacaataat aaaactttca acaacggatc tcttggcttc cacatcgatg aagaacgcag 181 cgaaatgcga taagtaatgt gaattgcaga attcagtgaa tcatcgaatc tttgaacgca 241 acttgcgccc tttggtattc cgaagggcat gcctgtttga gagtcatgaa aatctcaatc 301 cctcgggttt tattacctgt tggacttgga tttgggtgtt tgccgcgacc tgcaaaggac 361 gtcggctcgc cttaaatgtg ttagtgggaa ggtgattacc tgtcagcccg //

What I want to obtain from the whole data

VERSIONMH973850.1 JOURNAL Submitted (24-SEP-2018) Biology, Ege University, Genclik Caddesi, Izmir 35040,Turkiye FEATURES Location/Qualifiers source 1..410 /organism="Cryptococcus neoformans" /mol_type="genomic DNA" /isolate="OA2" /isolation_source="Soil sample" /db_xref="taxon:5207" misc_RNA <1..>410 /note="contains internal transcribed spacer 1, 5.8S ribosomal RNA, and internal transcribed spacer 2"

Which is the best way to accomplish this?

1 Answer 1

0

Here's a python3 code snippet that users the biopython library:

from Bio import Entrez

Entrez.email = '[email protected]'
handle = Entrez.esearch(db="nucleotide", term="Cryptococcus neoformans isolate OA2 internal transcribed spacer 1") # generates URL
record = Entrez.read(handle) # requests entity ids
id_list = record.get('IdList',None)

for x in id_list:
    handle = Entrez.efetch(db="nucleotide", id=x, retmode="xml") # makes query for each ID, returns XML format

    record = Entrez.read(handle) # parses XML format
    # print (record[0]) # print entire result (python dict)

    # this is parsing some fields you need
    print ('accession:',record[0].get('GBSeq_primary-accession',None))
    for item in record[0].get('GBSeq_feature-table',None)[0].get('GBFeature_quals',None):
        for k in item.keys():
            print (k, ':',item.get(k))

prints

accession: MH973850
GBQualifier_name : organism
GBQualifier_value : Cryptococcus neoformans
GBQualifier_name : mol_type
GBQualifier_value : genomic DNA
GBQualifier_name : isolate
GBQualifier_value : OA2
GBQualifier_name : isolation_source
GBQualifier_value : Soil sample
GBQualifier_name : db_xref
GBQualifier_value : taxon:5207

You'll have to finish the code yourself to get the exact keys/values you need. I didn't see any "country" field, except the journal publication locale.

If you don't use the code, at least use the retmode='XML' so you can easily parse the response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.