Hello everyone,
I sent a question earlier today about finding aliases, and someone was kind enough to provide quite a bit of help that sent me on the right track. My only issue is that the help was not in Python, and I have not been able at recreating the script on my system all day. This is the code from the answer I got earlier today.
$ esearch -db gene -query "TP53 [gene]" | efetch -format ft
1. TP53
Official Symbol: TP53 and Name: tumor protein p53 [Homo sapiens (human)]
Other Aliases: BCC7, BMFS5, LFS1, P53, TRP53
Other Designations: cellular tumor antigen p53; antigen NY-CO-13; mutant tumor protein 53; phosphoprotein p53; transformation-related protein 53; tumor protein 53; tumor supressor p53
Chromosome: 17; Location: 17p13.1
Annotation: Chromosome 17 NC_000017.11 (7668421..7687490, complement)
MIM: 191170
ID: 7157
Since then I have tried multiple different things, here are some examples.
summarysearch = Entrez.esearch(db = "gene", term = "TP53",retmax = "2")
genesummary = Entrez.read(summarysearch)
print(genesummary)
id_list = genesummary['IdList']
handle = Entrez.efetch(db = 'gene', id = id_list, rettype = 'db', retmode = 'text' )
print(handle.readline().strip())
and all I've gotten as output is
LOCUS ON745601 1503 bp mRNA linear PRI 30-OCT-2022
I really do need the fetch to give me the summary just like in the first example that was provided by GenoMax, and would really appreciate some help. I would also like to move the aliases to their own variable if that is possible as well.
Thank you!
Edit:
I have now tried this, and I am getting a little bit more information in a list, however, I am still missing the Aliases part that I wanted to begin with.
handle = Entrez.esearch(db = "nucleotide", term = 'TP53', retmax = "1")
rec_list = Entrez.read(handle)
handle.close()
print(rec_list['Count'])
print(len(rec_list['IdList']))
print(rec_list)
id_list = rec_list['IdList']
handles = Entrez.efetch(db = 'nucleotide', id = id_list, rettype = 'fasta')
recs = list(SeqIO.parse(handles, 'fasta' ))
handles.close()
print(recs)