I am trying to get a protein sequence using this command:

curl https://www.uniprot.org/uniprot/A2Z669.fasta

But I don't get any output:

$ curl https://www.uniprot.org/uniprot/A2Z669.fasta

And no file is created.


1 Answer 1


The URL https://www.uniprot.org/uniprot/A2Z669.fasta redirects to https://rest.uniprot.org/uniprotkb/A2Z669.fasta. You can see this if you open it in your browser: clicking on the first link will take you to the address of the second.

Now, curl doesn't follow redirects by default, you need the -L option for that (see man curl):

-L, --location

(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option makes curl redo the request on the new place. If used together with -i, --include or -I, --head, headers from all requested pages are shown.

So you need -L for curl to work here:

$ curl -L https://www.uniprot.org/uniprot/A2Z669.fasta
>sp|A2Z669|CSPLT_ORYSI CASP-like protein 5A2 OS=Oryza sativa subsp. indica OX=39946 GN=OsI_33147 PE=3 SV=1

Or, alternatively, you can use wget which does follow redirects by default:

$ wget "https://www.uniprot.org/uniprot/A2Z669.fasta" 
--2023-12-10 16:21:46--  https://www.uniprot.org/uniprot/A2Z669.fasta
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving www.uniprot.org (www.uniprot.org)...
Connecting to www.uniprot.org (www.uniprot.org)||:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://rest.uniprot.org/uniprot/A2Z669.fasta [following]
--2023-12-10 16:21:46--  https://rest.uniprot.org/uniprot/A2Z669.fasta
Resolving rest.uniprot.org (rest.uniprot.org)...
Connecting to rest.uniprot.org (rest.uniprot.org)||:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://rest.uniprot.org/uniprotkb/A2Z669.fasta [following]
--2023-12-10 16:21:46--  https://rest.uniprot.org/uniprotkb/A2Z669.fasta
Reusing existing connection to rest.uniprot.org:443.
HTTP request sent, awaiting response... 200 OK
Length: 314 [text/plain]
Saving to: ‘A2Z669.fasta.1’

A2Z669.fasta             100%[=======================================>]     314  --.-KB/s    in 0s      

2023-12-10 16:21:47 (8.57 MB/s) - ‘A2Z669.fasta.1’ saved [314/314]

That creates a A2Z669.fasta file in the current directory which will contain the sequence.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.