This is a test version of Biostars. For the public version, visit https://www.biostars.org.
PSSM (Position Specific Scoring Matrix) from NCBI convert to matrix format

When I run psi-blast (3 iterations) to download the PSSM (Position Specific Scoring Matrix), the files come up as ASN.1 files. How can i convert these ASN.1 files to matrices. The PSSMs should look like matrices with 20 columns (for 20 amino acids) and L rows (L=length of protein)

However, the files I download are ASN.1 files, which look like this:

numRows 28,         
numColumns 555,         
swissprot {accession "q2m32 9"}             
inst {          
repr raw,           
mol aa,         
length 555                  
{ 0, 10, 0 },           
{ 634267618256118,  10, -16 },
{ 0, 10, 0 },           
{ 129176519709001,  10, -16 },
{ 182041473572035,  10, -16 },
{ 292541684289281,  10, -16 }
.....

How can I download/convert this ASN.1 format to what a PSSM matrix is supposed to look like?

alignment sequence

1 answer

I have been looking for a resource to indicate what the 28 rows align with so I can programattically do this but have not found a resource yet. In the mean time you can upload your Scoremat.asn file to the pssm_viewer, choose the file, then click 'matrix view', and 'download matrix to file'.

EDIT: I got a response from Christiam C. at NCBI. The 28 rows are based off the order of the array NCBISTDAA_TO_AMINOACID (see definition below): https://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/src/algo/blast/core/blast_encoding.c#L115

I confirmed the order with a PSI-blast.

Hello!Do you have a script for batch conversion of Scoremat.asn to PSSM matrix format? Thank you for taking the time to answer me.

Hi, can you help me? I'm at my wit's end. Could you show me an example of Python parsing? Thank you very much !!!!!!

Hi @leeiqi,

I don't think I have the python script anymore. To do this you really just need to see the order of the amino acids in https://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/lxr/source/src/algo/blast/core/blast_encoding.c#0115 (see line 115) in which there are 28 I believe and have that amino acid order. So you need to parse out all the numbers using a regex matcher between

finalData {
      scores {

and

},
      lambda { 0, 10, 0 },

It should have a length that is a multiple of 28 and your amino acid length. So its a 1-d vector of (28 x n) and then you need to reshape it with python numpy so that it is 2-d as in (n x 28) where you have n rows and 28 columns. Then only keep the amino acids you need using list comprehension. Like you don't need '-','Z','U','*','O', 'J'... So those columns you would remove by their number and you have the PSSM!

Log in to answer this question.