Thanks! I installed Entrez Direct on my Win10 laptop and there are (as expected) some bugs when implementing the code with Git Bash (or perhaps cygwin). Briefly speaking, I have no problem running esearch -db gene -query "10627 [uid]", but when it becomes esearch -db gene -query "10627 [uid]" | elink -target protein or more, some error keep coming out. Am trying to fix it. Maybe I will install a WSL instead.
nquire -url https://eutils.ncbi.nlm.nih.gov/entrez/eutils/ elink.fcgi -id Unable,to,locate,xtract,executable.,Please,execute,the,following,nquire,dwn,ftp.ncbi.nlm.nih.gov,entrez,entrezdirect,xtract.UNSUPPORTED.gz,gunzip,f,xtract.UNSUPPORTED.gz,chmod,x,xtract.UNSUPPORTED -WebEnv MCID_6180802004ade96d2d580872 -dbfrom gene -db protein -cmd neighbor_history -linkname gene_protein -tool edirect -edirect 16.2 -edirect_os MSYS_NT
Unable to locate xtract executable. Please execute the following:
nquire -dwn ftp.ncbi.nlm.nih.gov entrez/entrezdirect xtract.UNSUPPORTED.gz
gunzip -f xtract.UNSUPPORTED.gz
chmod +x xtract.UNSUPPORTED
Please post a few example gene ID. EntrezDirect would be one way of getting this done programmatically.
Have added a few. Thanks for the recommendations, I briefly skimmed through and this looks similar to Biopython. In fact, I wanted to try directly accessing the protein sequences from Entrez, but the conversion between gene IDs and protein IDs (GenBank protein accession) is quite ambiguous, by which I mean there are a lot of multi-to-multi mappings. I used bioDBnet to do the conversion. As an example, I can hardly distinguish which one is the canonical protein ID for gene ID 2:
If you are referencing a
generecord ID then it points to a number of protein sequence. For example for277gene ID you have the following records in protein database.(All sequence trimmed due to space constraint)
You could also
UniProt sequence(which will likely get you one sequence) using the above searchThanks for the great demo! As I mentioned in my reply to Istvan Albert I actually need only one canonical protein sequence from one
gene ID.The second script looks like what I need! I just installed EntrezDirect and am still dealing with some bugs, so I cannot test the script to
gene ID10627, which is a one-on-multiple-protein mapping gene. I am not familiar with awk and am not sure where in the script UniProt is linked, but it would be great if Entrez could directly do so. Will try test inBiopythonlater to see the results.Use
condato install EntrezDirect and that should take care of the problems. I showed you examples of searches for 10627 and 103910 below.Since a gene by definition could be connected to multiple proteins, what is it that you are asking really?
What is the goal? How would/should the multiple mapping be resolved? Are you asking for a database to resolve that for you?
Edit: also I would not call this "accurate" protein ids. There is nothing "accurate" about collapsing multiple proteins into a single gene. If anything it is an "inaccurate" mapping.
Thanks for the reminder and have revised the wording in my post. You are right that there could be a bunch of proteins connected to one gene. However, the reason I have to figure out one canonical protein sequence is that I need to learn the representation of proteins from a protein-protein interaction dataset, where the proteins are denoted only by
gene IDs (I am also quite confused about this). I understand the protein sequence I choose for the downstream might not be the real isoform of the protein actually interacting with the other proteins, but for my downstream task, a canonical sequence is enough.In fact, UniProt has the so-called "canonical sequence" posted for each protein, but I just need to resolve the multi-mapping stuff. For example,
gene ID10627 is mapped to bothUniProt accessionP19105 (akagene symbolMYL12A) andUniProt accessionO14950 (akagene symbolMYL12B, mapped along withgene ID103910) in UniProt. In NCBI the gene IDs are clearly distinct, and in UniPort the gene symbols for the two proteins are also different. But it is just mapped to two of them.While I did notice that in NCBI Gene database I can download a single CDS protein sequence for one gene, I am not aware of how to do so in Entrez...