Answers.Body: <p>Entrez has the tags [journal], [volume], [page number], [title], [year] and [author] to identify all sequences from a given publication. You will find a full list of tags <a href="https://www.ncbi.nlm.nih.gov/nuccore/advanced" rel="nofollow noreferrer">here</a> from the drop down menu.</p>
  <p>Thus,</p>
  <pre><code>query = &quot;Microbacterium[Organism] AND Nature[Journal] AND 528[volume] AND Bai[author] AND 364[page number]&quot;
  </code></pre>
  <p>This will identify all <em>Microbacterium</em> genome sequences associated with Bai <em>et al</em> (2015) Nature 528:364- and is <a href="https://www.ncbi.nlm.nih.gov/nuccore/?term=Microbacterium%5BOrganism%5D%20AND%20NATURE%5BJournal%5D%20AND%20nature%5BJournal%5D%20AND%20528%5Bvolume%5D%20AND%20Bai%5Bauthor%5D%20AND%20364%5Bpage%20number%5D" rel="nofollow noreferrer">here</a>.</p>
  <p>For practical purposes I routinely search using the organism and author tags for their sequence output.</p>
  <hr />
  <p>The example given (post-edit) was</p>
  <blockquote>
  <p>Kim KK et al., &quot;Microbacterium aquimaris sp. nov., isolated from seawater.&quot;, Int J Syst Evol Microbiol, 2008 Jul;58(Pt 7):1616-20</p>
  </blockquote>
  <pre><code>query = &quot;Microbacterium[Organism] AND 58[volume] AND Kim[author] AND 1616[page number] AND 2008[year]&quot;
  </code></pre>
  <p>I removed the [journal] tag because the abbreviation it uses is a bit unusual and replaced it with [year]. Still works <a href="https://www.ncbi.nlm.nih.gov/nuccore/?term=Microbacterium%5BOrganism%5D%20AND%2058%5Bvolume%5D%20AND%20Kim%5Bauthor%5D%20AND%201616%5Bpage%20number%5D%20AND%202008%5Byear%5D" rel="nofollow noreferrer">here</a>.</p>
  <hr />
  <p>From the comments ... if only published sequences were required then using the <code>range</code> function and <code>[publication date]</code> is one way in ...</p>
  <pre><code>query = &quot;Microbacterium[Organism] AND 2000/1/1:2020/1/1[publication date]&quot;
  </code></pre>
  <p>The best strategy is to use the <code>[author]</code> because data production tends to be dominated by a small number of groups.</p>
  <hr />
  <p><strong>Comments of Comments</strong></p>
  <p>Why isn't searching working. The following search works</p>
  <pre><code>query = &quot;Microbacterium[Organism] AND (all[filter] NOT partial[filter])&quot;
  </code></pre>
  <p>The term it doesn't like is <code>latest refseq[filter]</code> if that is removed it will work. <code>refseq</code> works, but it doesn't like <code>latest</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T19:03:57.200Z
Answers.Text: I think the OP wants to limit the results to only those genomes whose NCBI BioProject entry includes a `Publications` field.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T19:08:20.597Z
Answers.Text: @terdon I don't believe there is a tag `[publication]`, there is `[publication date]`, which is better than `[year]`. However, it's the same answer, the sequence output of most fields are represented only by a small number of authors and only those authors are searched.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T20:28:21.000Z
Answers.Text: @M__ thanks a lot for your help ! your range idea it's pretty clever, it will already be much better than checking by hand!
Answers.UserDisplayName: Marine Bergot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T20:32:03.423Z
Answers.Text: Thanks @MarineBergot please remember to "accept" if it's useful. You can always switch "accepted" posts if there's a better way posted later.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T20:35:42.230Z
Answers.Text: @M__ by the way, do you have any idea why my current research is not returning anything?
Answers.UserDisplayName: Marine Bergot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T21:22:19.650Z
Answers.Text: @MarineBergot I've answered in the comments of comments
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T21:35:13.623Z
Answers.Text: @M__ thanks for your answer. I arrived in the same point but i need both, latest and refseq. For me latest is working with organism and no partial but refseq is not working even alone. do you have results with Microbacterium[Organism] AND refseq[Filter]? could it be related to version ?
Answers.UserDisplayName: Marine Bergot
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-09T14:06:58.950Z
Answers.Text: @MarineBergot its the database. The output of the above search using the nucleotide database is [here](https://www.ncbi.nlm.nih.gov/nuccore/?term=Microbacterium%5BOrganism%5D%20AND%20refseq%5BFilter%5D)
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-08T18:55:35.073Z
Answers.LastActivityDate: 2023-02-08T21:23:55.700Z
Answers.LastEditDate: 2023-02-08T21:23:55.700Z
Answers.UserDisplayName: M__
Body: <p>I'm trying to reproduce a complex manual search on NCBI using BioPython, but obviously something is not right. My command line is not working, but I'd especially like a way to have an accurate search where I can select only the genomes related to a published paper. Is there an easy way to do that?</p>
  <p>I want to limit my results to only those genomes that i) have an NCBI BioProject entry and ii) that BioProject entry contains a <code>Publications</code> field.</p>
  <p>For example, let's say I want all the genomes of Microbacterium, the latest version, from RefSeq and not partial (this is what I tried to write but something is not working) and I would like to add one more filter. Take, among the remaining/selected genomes, only the ones related to published papers.</p>
  <p>For this strain, we have a related paper:
  <a href="https://www.ncbi.nlm.nih.gov/bioproject/PRJNA669461/" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/bioproject/PRJNA669461/</a></p>
  <p>For this one, we do not:
  <a href="https://www.ncbi.nlm.nih.gov/bioproject/PRJNA608230/" rel="nofollow noreferrer">https://www.ncbi.nlm.nih.gov/bioproject/PRJNA608230/</a></p>
  <p>and I really would like to not have to check 100 genomes manually, but I don't know how to manage it.</p>
  <p>I tried:</p>
  <pre class="lang-py prettyprint-override"><code>query = &quot;Microbacterium[Organism] AND latest refseq[filter] AND (all[filter] NOT
  partial[filter])&quot;
  handle = Entrez.esearch(term=query, db=&quot;Assembly&quot;, retmax=600)
  ids = Entrez.read(handle)[&quot;IdList&quot;]
  </code></pre>
  <p>And after this, I'm just using a <code>for</code> loop to get genomes, but my query is not good and it is not handling the problem of the publication.</p>
  <p>Thanks for any help!</p>
  <hr />
  <p>Edit : as I need to search in the db Assembly unfortunately the answer with the flag author or date is not working</p>
  
Tags: <python><biopython><ncbi>
Title: how to do manual search on NCBI with biopython and add link to publication
ThreadText: # how to do manual search on NCBI with biopython and add link to publication
  
  (Asked by: username_0 on 2023-02-08)
  
  I'm trying to reproduce a complex manual search on NCBI using BioPython, but obviously something is not right. My command line is not working, but I'd especially like a way to have an accurate search where I can select only the genomes related to a published paper. Is there an easy way to do that?
  
  I want to limit my results to only those genomes that i) have an NCBI BioProject entry and ii) that BioProject entry contains a `Publications` field.
  
  For example, let's say I want all the genomes of Microbacterium, the latest version, from RefSeq and not partial (this is what I tried to write but something is not working) and I would like to add one more filter. Take, among the remaining/selected genomes, only the ones related to published papers.
  
  For this strain, we have a related paper:
  <https://www.ncbi.nlm.nih.gov/bioproject/PRJNA669461/>
  
  For this one, we do not:
  <https://www.ncbi.nlm.nih.gov/bioproject/PRJNA608230/>
  
  and I really would like to not have to check 100 genomes manually, but I don't know how to manage it.
  
  I tried:
  
  ```py
  query = "Microbacterium[Organism] AND latest refseq[filter] AND (all[filter] NOT
  partial[filter])"
  handle = Entrez.esearch(term=query, db="Assembly", retmax=600)
  ids = Entrez.read(handle)["IdList"]
  
  ```
  
  And after this, I'm just using a `for` loop to get genomes, but my query is not good and it is not handling the problem of the publication.
  
  Thanks for any help!
  
  ---
  
  Edit : as I need to search in the db Assembly unfortunately the answer with the flag author or date is not working
  
  **Tags:** python, biopython, ncbi
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-02-08. Score: 0 | Accepted answer
  
  Entrez has the tags [journal], [volume], [page number], [title], [year] and [author] to identify all sequences from a given publication. You will find a full list of tags [here](https://www.ncbi.nlm.nih.gov/nuccore/advanced) from the drop down menu.
  
  Thus,
  
  ```
  query = "Microbacterium[Organism] AND Nature[Journal] AND 528[volume] AND Bai[author] AND 364[page number]"
  
  ```
  
  This will identify all *Microbacterium* genome sequences associated with Bai *et al* (2015) Nature 528:364- and is [here](https://www.ncbi.nlm.nih.gov/nuccore/?term=Microbacterium%5BOrganism%5D%20AND%20NATURE%5BJournal%5D%20AND%20nature%5BJournal%5D%20AND%20528%5Bvolume%5D%20AND%20Bai%5Bauthor%5D%20AND%20364%5Bpage%20number%5D).
  
  For practical purposes I routinely search using the organism and author tags for their sequence output.
  
  ---
  
  The example given (post-edit) was
  
  > Kim KK et al., "Microbacterium aquimaris sp. nov., isolated from seawater.", Int J Syst Evol Microbiol, 2008 Jul;58(Pt 7):1616-20
  
  ```
  query = "Microbacterium[Organism] AND 58[volume] AND Kim[author] AND 1616[page number] AND 2008[year]"
  
  ```
  
  I removed the [journal] tag because the abbreviation it uses is a bit unusual and replaced it with [year]. Still works [here](https://www.ncbi.nlm.nih.gov/nuccore/?term=Microbacterium%5BOrganism%5D%20AND%2058%5Bvolume%5D%20AND%20Kim%5Bauthor%5D%20AND%201616%5Bpage%20number%5D%20AND%202008%5Byear%5D).
  
  ---
  
  From the comments ... if only published sequences were required then using the `range` function and `[publication date]` is one way in ...
  
  ```
  query = "Microbacterium[Organism] AND 2000/1/1:2020/1/1[publication date]"
  
  ```
  
  The best strategy is to use the `[author]` because data production tends to be dominated by a small number of groups.
  
  ---
  
  **Comments of Comments**
  
  Why isn't searching working. The following search works
  
  ```
  query = "Microbacterium[Organism] AND (all[filter] NOT partial[filter])"
  
  ```
  
  The term it doesn't like is `latest refseq[filter]` if that is removed it will work. `refseq` works, but it doesn't like `latest`.
  
  > **Comments:**
  > **username_2**: I think the OP wants to limit the results to only those genomes whose NCBI BioProject entry includes a `Publications` field.  
  > **username_1**: @username_2 I don't believe there is a tag `[publication]`, there is `[publication date]`, which is better than `[year]`. However, it's the same answer, the sequence output of most fields are represented only by a small number of authors and only those authors are searched.  
  > **username_0**: @username_1 thanks a lot for your help ! your range idea it's pretty clever, it will already be much better than checking by hand!  
  > **username_1**: Thanks @username_0 please remember to "accept" if it's useful. You can always switch "accepted" posts if there's a better way posted later.  
  > **username_0**: @username_1 by the way, do you have any idea why my current research is not returning anything?  
  > **username_1**: @username_0 I've answered in the comments of comments  
  > **username_0**: @username_1 thanks for your answer. I arrived in the same point but i need both, latest and refseq. For me latest is working with organism and no partial but refseq is not working even alone. do you have results with Microbacterium[Organism] AND refseq[Filter]? could it be related to version ?  
  > **username_1**: @username_0 its the database. The output of the above search using the nucleotide database is [here](https://www.ncbi.nlm.nih.gov/nuccore/?term=Microbacterium%5BOrganism%5D%20AND%20refseq%5BFilter%5D)  
  
  ---
  
  