Answers.Body: <p>I believe I figured out a way to do this for my particular example (although in general cases Adrian's answer works). To get release 5.57 (an earlier release) of chromosome X of Drosophila melanogaster, I believe you can go to the <a href="https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000001215.4/" rel="nofollow noreferrer">Datasets Genome page</a> of D. melanogaster, scroll down to the Revision History and select Release 5, and at the top of the page, NCBI lets you click on a 'datasets' or 'curl' box to copy the exact command line argument needed to download a GFF (and other files) of that whole genome. Then, I believe it should be possible to open the gff in Python using a package like gffutils, and filter only for chromosome X rows, and then write those rows to a new gff file.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-21T10:25:39.587Z
Answers.Text: If you are willing to filter, there is no need for python or writing a whole script. A simple `grep -P '^NC_004354.3\t' foo.gff > chrX.gff` will do.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-21T21:09:38.077Z
Answers.Text: Did not realize I could do that, thanks. Although you'd probably have to add a bit to this command to also preserve the header lines. Maybe (grep "^#" foo.gff; grep -P '^NC_004354.3\t' foo.gff) > chrX.gff
Answers.UserDisplayName: arara
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-20T21:16:50.567Z
Answers.LastActivityDate: 2022-11-20T21:16:50.567Z
Answers.UserDisplayName: arara
Answers.Body: <p>my suggestion would be to go via the assembly page.
  For your example link, I would</p>
  <ol>
  <li>Click the link to the BioProject: PRJNA164</li>
  <li>On the right side, under &quot;Related information&quot; choose the <a href="https://www.ncbi.nlm.nih.gov/assembly/GCF_000001215.4" rel="nofollow noreferrer">assembly</a></li>
  <li>On the assembly page, under &quot;Access the data&quot; on the right side, I would choose &quot;FTP directory for RefSeq assembly&quot;</li>
  </ol>
  <p>Once in the RefSeq folder, copy the link to the <code>*_genomic.gff.gz</code> and use wget.</p>
  <pre><code>wget https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/215/GCF_000001215.4_Release_6_plus_ISO1_MT/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.gff.gz
  </code></pre>
  <hr />
  <p><strong>Edit</strong>: The initial question requested an older versions, which can be found in RefSeq's <a href="https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/" rel="nofollow noreferrer">archive</a> of prior releases. For this specific Drosophila assembly chromosome X, the version 5 can be found at <a href="https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/CHR_X/NC_004354.gff" rel="nofollow noreferrer">https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/CHR_X/NC_004354.gff</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-20T21:12:16.777Z
Answers.Text: This does show how to wget from NCBI, although it wouldn't work on the specific case I mentioned. This gives me the whole genome, although I'm curious on getting a single chromosome. Also it will give me release 6 (the latest one), whereas my scenario was for release 5. However I think I found a way to do this.
Answers.UserDisplayName: arara
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-21T07:32:48.507Z
Answers.Text: Pardon, the RefSeq archive seems what you are looking for. Have a look at https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/.  The path to the X chromosome's gff should be straight forward. https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/CHR_X/NC_004354.gff
Answers.UserDisplayName: Adrian Sven Geissler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-21T21:09:26.803Z
Answers.Text: That's exactly it! Could you edit these links into your main answer so I can mark your comment as accepted?
Answers.UserDisplayName: arara
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-22T09:20:59.723Z
Answers.Text: You're welcome. Glad to have helped
Answers.UserDisplayName: Adrian Sven Geissler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-20T20:30:35.443Z
Answers.LastActivityDate: 2022-11-22T09:19:43.710Z
Answers.LastEditDate: 2022-11-22T09:19:43.710Z
Answers.UserDisplayName: Adrian Sven Geissler
Body: <p>Say I want to use wget to download a gff file for the X chromosome of release 5.57 of the Drosophila melanogaster genome. The NCBI page with the gff file for just this <a href="https://www.ncbi.nlm.nih.gov/nuccore/NC_004354.3" rel="nofollow noreferrer">is here</a>.</p>
  <p>However, I do not see any way to directly wget the gff from this page. What I can do is click &quot;Send to&quot; at the top, select File, and change the Format dropdown to GFF3, and finally click 'Create File', and the gff file downloads onto my computer.</p>
  <p>But then I lose the ability to use the -a flag to log the download details, I can't download the gff using wget from a remote server directly but instead I need to download it locally and then upload it, etc. Is there any way to use wget to download gff files from NCBI programmatically instead of having to download it manually from the website?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-20T17:44:12.110Z
Comments.Text: Are you looking for [these](https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/215/GCF_000001215.4_Release_6_plus_ISO1_MT/)?
Comments.UserDisplayName: user172818
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-11-20T21:18:54.550Z
Comments.Text: @user172818 If you mean my example, not exactly, I'm looking for release a 5.57 gff based on chromosome X, that link lets me download a release 6 whole genome gff. But I think I figured out what to do, and I posted an answer to my question.
Comments.UserDisplayName: arara
Tags: <phylogenetics><bash><data-download><gff3>
Title: How to wget a gff from NCBI database?
ThreadText: # How to wget a gff from NCBI database?
  
  (Asked by: username_0 on 2022-11-20)
  
  Say I want to use wget to download a gff file for the X chromosome of release 5.57 of the Drosophila melanogaster genome. The NCBI page with the gff file for just this [is here](https://www.ncbi.nlm.nih.gov/nuccore/NC_004354.3).
  
  However, I do not see any way to directly wget the gff from this page. What I can do is click "Send to" at the top, select File, and change the Format dropdown to GFF3, and finally click 'Create File', and the gff file downloads onto my computer.
  
  But then I lose the ability to use the -a flag to log the download details, I can't download the gff using wget from a remote server directly but instead I need to download it locally and then upload it, etc. Is there any way to use wget to download gff files from NCBI programmatically instead of having to download it manually from the website?
  
  **Tags:** phylogenetics, bash, data-download, gff3
  
  > **Comments:**
  > **username_1**: Are you looking for [these](https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/215/GCF_000001215.4_Release_6_plus_ISO1_MT/)?  
  > **username_0**: @username_1 If you mean my example, not exactly, I'm looking for release a 5.57 gff based on chromosome X, that link lets me download a release 6 whole genome gff. But I think I figured out what to do, and I posted an answer to my question.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2022-11-20. Score: 3 | Accepted answer
  
  my suggestion would be to go via the assembly page.
  For your example link, I would
  
  1. Click the link to the BioProject: PRJNA164
  2. On the right side, under "Related information" choose the [assembly](https://www.ncbi.nlm.nih.gov/assembly/GCF_000001215.4)
  3. On the assembly page, under "Access the data" on the right side, I would choose "FTP directory for RefSeq assembly"
  
  Once in the RefSeq folder, copy the link to the `*_genomic.gff.gz` and use wget.
  
  ```
  wget https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/215/GCF_000001215.4_Release_6_plus_ISO1_MT/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.gff.gz
  
  ```
  
  ---
  
  **Edit**: The initial question requested an older versions, which can be found in RefSeq's [archive](https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/) of prior releases. For this specific Drosophila assembly chromosome X, the version 5 can be found at <https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/CHR_X/NC_004354.gff>
  
  > **Comments:**
  > **username_0**: This does show how to wget from NCBI, although it wouldn't work on the specific case I mentioned. This gives me the whole genome, although I'm curious on getting a single chromosome. Also it will give me release 6 (the latest one), whereas my scenario was for release 5. However I think I found a way to do this.  
  > **username_3**: Pardon, the RefSeq archive seems what you are looking for. Have a look at https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/.  The path to the X chromosome's gff should be straight forward. https://ftp.ncbi.nlm.nih.gov/genomes/archive/old_refseq/Drosophila_melanogaster/RELEASE_5/CHR_X/NC_004354.gff  
  > **username_0**: That's exactly it! Could you edit these links into your main answer so I can mark your comment as accepted?  
  > **username_3**: You're welcome. Glad to have helped  
  
  ---
  
  ### Answer by username_0 on 2022-11-20. Score: 1
  
  I believe I figured out a way to do this for my particular example (although in general cases username_3's answer works). To get release 5.57 (an earlier release) of chromosome X of Drosophila melanogaster, I believe you can go to the [Datasets Genome page](https://www.ncbi.nlm.nih.gov/data-hub/genome/GCF_000001215.4/) of D. melanogaster, scroll down to the Revision History and select Release 5, and at the top of the page, NCBI lets you click on a 'datasets' or 'curl' box to copy the exact command line argument needed to download a GFF (and other files) of that whole genome. Then, I believe it should be possible to open the gff in Python using a package like gffutils, and filter only for chromosome X rows, and then write those rows to a new gff file.
  
  > **Comments:**
  > **username_2**: If you are willing to filter, there is no need for python or writing a whole script. A simple `grep -P '^NC_004354.3\t' foo.gff > chrX.gff` will do.  
  > **username_0**: Did not realize I could do that, thanks. Although you'd probably have to add a bit to this command to also preserve the header lines. Maybe (grep "^#" foo.gff; grep -P '^NC_004354.3\t' foo.gff) > chrX.gff  
  
  ---
  
  