Answers.Body: <p>This can be done by using the "Search details" as a search term in <code>Entrez.esearch</code>:</p>
  
  <pre class="lang-python prettyprint-override"><code>import os
  OPJ = os.path.join
  base_dir = os.getcwd()
  
  from Bio import Entrez
  Entrez.email = "my_email_here"
  query = "ANOS1[gene name] AND refseq[filter]"
  handle = Entrez.esearch(term=query, db="nuccore", retmax=400)
  ids = Entrez.read(handle)["IdList"]
  with open(OPJ(base_dir, "ANOS1_orthologs_max400_ids.txt"), "w") as ids_file:
      ids_file.write("\n".join(ids))
      ids_file.write("\n")
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T12:45:05.873Z
Answers.Text: [Rubber duck debugging](https://rubberduckdebugging.com/) at its finest :)
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T13:28:23.097Z
Answers.Text: @terdon I did not know this expression. I learned something new today :). Regarding off-topicness, I think the question can still be useful to others, in that it gives an almost-working example of something one may try to do in a bioinformatics context.
Answers.UserDisplayName: bli
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T13:30:39.320Z
Answers.Text: useful, yes, but not on topic since the actual problem was a very simple mistake and therefore the answer is unlikely to help others. You could, if you want, change it around: ask how you can reproduce the manual search in python and then post your (corrected) solution as an answer. That would be great!
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T13:37:29.463Z
Answers.Text: @terdon I see your point. I updated the question and answer.
Answers.UserDisplayName: bli
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T14:49:39.103Z
Answers.Text: Perfect, thanks! I would upvote, but I already had :)
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-09T12:34:19.233Z
Answers.LastActivityDate: 2018-03-09T13:37:00.753Z
Answers.LastEditDate: 2018-03-09T13:37:00.753Z
Answers.UserDisplayName: bli
Body: <p>I'm trying to make a Biopython script that reproduces a manual search on the NCBI website.</p>
  
  <p>My manual search gives me the following URL:</p>
  
  <p><a href="https://www.ncbi.nlm.nih.gov/nuccore?term=ANOS1[gene%20name]%20AND%20refseq[filter]" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/nuccore?term=ANOS1[gene%20name]%20AND%20refseq[filter]</a></p>
  
  <p>And the "Search details" box indicates:<code>ANOS1[gene name] AND refseq[filter]</code>.</p>
  
  <p>I get 338 results that I "Send to" "File" as "GI List", save as <code>ANOS1_orthologs_manual.txt</code>.</p>
  
  <p><strong>How can I do the same using Biopython?</strong></p>
  
Tags: <python><public-databases>
Title: How can I reproduce a manual NCBI search with Biopython Entrez module?
ThreadText: # How can I reproduce a manual NCBI search with Biopython Entrez module?
  
  (Asked by: username_0 on 2018-03-09)
  
  I'm trying to make a Biopython script that reproduces a manual search on the NCBI website.
  
  My manual search gives me the following URL:
  
  <https://www.ncbi.nlm.nih.gov/nuccore?term=ANOS1[gene%20name]%20AND%20refseq[filter]>
  
  And the "Search details" box indicates:`ANOS1[gene name] AND refseq[filter]`.
  
  I get 338 results that I "Send to" "File" as "GI List", save as `ANOS1_orthologs_manual.txt`.
  
  **How can I do the same using Biopython?**
  
  **Tags:** python, public-databases
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-03-09. Score: 6 | Accepted answer
  
  This can be done by using the "Search details" as a search term in `Entrez.esearch`:
  
  ```python
  import os
  OPJ = os.path.join
  base_dir = os.getcwd()
  
  from Bio import Entrez
  Entrez.email = "my_email_here"
  query = "ANOS1[gene name] AND refseq[filter]"
  handle = Entrez.esearch(term=query, db="nuccore", retmax=400)
  ids = Entrez.read(handle)["IdList"]
  with open(OPJ(base_dir, "ANOS1_orthologs_max400_ids.txt"), "w") as ids_file:
      ids_file.write("\n".join(ids))
      ids_file.write("\n")
  
  ```
  
  > **Comments:**
  > **username_1**: [Rubber duck debugging](https://rubberduckdebugging.com/) at its finest :)  
  > **username_0**: @username_1 I did not know this expression. I learned something new today :). Regarding off-topicness, I think the question can still be useful to others, in that it gives an almost-working example of something one may try to do in a bioinformatics context.  
  > **username_1**: useful, yes, but not on topic since the actual problem was a very simple mistake and therefore the answer is unlikely to help others. You could, if you want, change it around: ask how you can reproduce the manual search in python and then post your (corrected) solution as an answer. That would be great!  
  > **username_0**: @username_1 I see your point. I updated the question and answer.  
  > **username_1**: Perfect, thanks! I would upvote, but I already had :)  
  
  ---
  
  