Archive | PeptideShaker RSS for this section

Modify Protein Database Using Regular Expression

I posted a blog earlier regarding requirements for protein database using PeptideShaker. That is to have a decoy sequence and having a tag “_REVERSED” for each decoy sequence. How can I add the tag to all protein (tens of thousand) entries?
Regular expression used in various systems is very useful to convert text in a certain manner. I am going to show you one way to do this. First I am going to use a text editor called EditPad Pro. This is a great text editor and you can use many tools for free, but for full version you have to pay.

Once you installed the program and open your fasta file that contains both target and decoy sequences with this application. There are many applications to create targe+decoy sequences, so I am not discussing about it here. In this example, I used COMPASS to generate the file. Then go Find or CTL+F to search & replace text. You should see a window like this below. This example is bovine sequences from Uniprot, which is recommended by Peptide Shaker.


You see two while boxes at the bottom, one for searching text, and the other one is for the text replaced with.

Before you do any operation, you need to check how many entries in this fasta database.  To do it, just type “^>“, select regular expression option and start from beginning and click the button for count matches. The hat “^” represents the beginning of each line.


And remember this number (48466 entries), just write it down somewhere. Then look at the first and second entry,

>Tr|A0JB29|A0JB29_BOVIN Bucentaur-2 OS=Bos taurus..

>DECOY_tr|A0JBZ9|A0JBZ9_BOVIN Bucentaur-2 OS=Bos taurus..

You want to remove “DECOY_tr” and then add “_REVERSED” tag right before the second “|” for every entry in the database.

>Tr|A0JB29_REVERSED|A0JB29_BOVIN Bucentaur-2 OS=Bos taurus..

It is pretty easy to do for a few entries, but how about another 24 thousands?

Let’s look at the entry more carefully. Each entry starts with “>DECOY_” and two alphabets (Tr), then the protein ID is separated by two “|”s.


You don’ t necessarily have to break up into two parts, but this is just an exercise and this will make it more flexible in the future. Here is the regular expression you need to capture the beginning of each entry.


The first ( ) will capture the “Tr” part and second ( ) will capture protein ID part “AoJB29”. The square bracket [ ] represents one letter that matches the character inside of the bracket.  The pipe “|” is a special character, so you need to use backslash followed by “|”. “*” is a wild card that can be any character, and if you have “*.*”, it will contain any characters until it finds the next “|”.

OK, let’s see if it works. You select regular expression option, and start from beginning. Then hit search.


Can you see the text in the first entry which is highlighted in blue? Try hitting search a few times to see if it finds the right piece from each entry.

Then try again by selecting regular expression and start from beginning. This time, you click “Count matches” instead of “Search”.


You see it found the search text for 24233 times. Since this is exactly the half of 48466 (all entries), the regular expression successfully capture all decoy entries.

Then how can you replace the text with “_REVERSED” tag? This is the regular expression for the replacement.


\1 is the first part “tr” and \2 is the second part “A0JB29”. Then tag is added followed by a pipe. Try testing a few more to see if it changes correctly. If it does, click “Replace All”. Finally, check the entry by eyes to see everything goes ok. That’s it!


PeptideShaker Database Requirements (0.22.4 or earlier)

PeptideShaker likes specific format for database if you don’t use searchGUI. They recommend Uniprot database. But occasionally I want to use my own database. There are two specific requirements for correct database in PeptideShaker.

1) It needs decoy sequences.

2)Accession number for decoy sequence has “_REVERSED” tag.

For 1), if you don’t contain decoy sequence, it complains “No Decoys Found”.


For 2), if the tag is not correctly added, no unique accession error appears.


So the correct fasta format for PeptideShaker is



These requirements are a little bit problematic. I also use IDPicker for MS/MS spectra analysis and it uses decoy tag before the accession number. Well, all I have to do is to create two databases and search with different databases for IDPicker and PeptideShaker.

If you are using searchGUI to search your MS/MS spectrum with OMSSA & X!tandem, you don’t have to worry about these requirements. The software will take care of them.

%d bloggers like this: