This is a test version of Biostars. For the public version, visit https://www.biostars.org.
download protein sequences form uniprot that do not contain ambiguous amino acids

Hi - I need to download random protein sequences from uniprot. I can do this quite easily using something like reviewed:yes&random=yes

However I do not want to retrieve any sequences that include ambiguous amino acids such as 'B' or 'X'. Is there a search parameter that can specify this? Or will I need to check and throw away a sequence if it contains them?

Thanks.

uniprot protein

3 answers

This can be done at the UniProt sparql endpoint using this query.

PREFIX up:<http://purl.uniprot.org/core/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?protein ?sequence
WHERE {
?protein up:reviewed true .
?protein up:sequence ?sequenceConcept .
?sequenceConcept rdf:value ?sequence .
FILTER ( ! contains(?sequence, 'X')) .
FILTER ( ! contains(?sequence, 'B')) .
FILTER ( ! contains(?sequence, 'Z')) .
}

You can get a nearly FASTA file from the CSV download using this query (just strip the quotes out)

PREFIX up:<http://purl.uniprot.org/core/>
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?fasta
WHERE {
?protein up:reviewed true .
?protein up:sequence ?sequenceConcept .
?sequenceConcept rdf:value ?sequence .
FILTER ( ! contains(?sequence, 'X')) .
FILTER ( ! contains(?sequence, 'B')) .
FILTER ( ! contains(?sequence, 'Z')) .
BIND(concat('>',SUBSTR(STR(?protein),33),'\n',?sequence) AS ?fasta)
}

On the UniProt website there is no way to use text search criteria to query for (or exclude) entries whose sequence contain a certain type of amino acid.

UniProtKB/Swiss-Prot release 2014_09 (due out tomorrow) will contain 2360 sequences with 'B', 'X' or 'Z'. You could either find these 2360 entries first (in a local copy of UniProtKB/Swiss-Prot) and then discard them if your website query happens to retrieve one of them, or, as you suggest, inspect the sequences of your retrieved entries and discard them if they contain the unwanted amino acids.

using my tool https://github.com/lindenb/jvarkit/wiki/UniprotFilterJS

$ cat filter.js
function accept(e)
    {
    var s = e.sequence.value.toUpperCase();
    return (s.indexOf("X")==-1 && s.indexOf("B")==-1);
    }
accept(entry);

and

curl -skL "ftp://ftp.uniprot.org/pub/databases/uniprot/current_release/knowledgebase/complete/uniprot_sprot.xml.gz" | gunzip -c |java -jar dist-1.139/uniprotfilterjs.jar  -f filter.js  > filtered.xml

Log in to answer this question.