-
Notifications
You must be signed in to change notification settings - Fork 3
multiplierz.mzTools.pep2gene
This module contains the Pep2Gene algorithm for rapid protein and gene assignment from peptide data. Briefly, Pep2Gene works by compiling a 4-mer -to- protein lookup database along with the gene data associated with each protein. Using this, the proteins containing a given peptide can be rapidly determined by first using the 4-mer matches to radically narrow down the search space. Pep2Gene database compilation takes less than half an hour on typical computers, for most mammalian proteomes, and annotation of thousands of peptides can be performed in minutes.
Note that, in order to obtain mapping data for the protein-to-gene step, the database compilation step sends a query to the NCBI Uniprot database; this therefore requires an internet connection.
This generates a Pep2Gene database for the protein sequences in the provided FASTA file. labelParser must be a function which returns a Uniprot protein accession when given a sequence header from the FASTA file. distinguish_leucine determines whether peptides distinguished only by I/L replacement should be considered distinct.
add_gene_ids(target_files, p2g_database, target_sheet = None, outputfile = None, inPlace = False, distinguish_leucine = True)
This uses a Pep2Gene database to annotate a provided PSM report with gene and protein assignments. The target_files argument can be the path(s) to a Multiplierz PSM report, or list of such reports, in any file format; p2g_database must be a file produced by create_fasta_index. For Excel files target_sheet can be used to specify which of a multi-sheet file should be annotated. distinguish_leucine must be False if the same parameter was False when generating the database file.
Pep2Gene works by compiling a set of lookup tables ahead of time, which (thanks to the highly efficient Python hashtable implementation) allow O(1) indexing into large sets of protein names, gene names, and peptide fragments. The database compilation step in create_fasta_index() has two primary components:
- The set of protein accessions present in the target FASTA file are extracted, and a set of queries are made to the Uniprot database to obtain a protein-to-gene lookup table for the protein set.
- Every protein sequence in the FASTA file is decomposed into a set of successive 4-mers; e.g., the peptide sequence 'PEPTIDE' would become the set ('PEPT', 'EPTI', 'PTID', 'TIDE'). A 4-mer-to-protein lookup table is created whose keys are individual 4-mers found in the FASTA file sequences, and the values of which are exhaustive lists of every protein in the file that contained the given 4-mer.
These tables, along with the original FASTA data, are written into the .pep2gene file as a compressed Pickle archive.
With these tables, add_gene_ids() can efficiently lookup the protein and genes corresponding to a specified peptide.
- Each peptide is decomposed into a set of 4-mers, identically to the process performed on whole protein sequences above.
- Using the 4-mer-to-protein lookup table, a set of proteins is obtained for every 4-mer in the decomposition. Since the peptide, necessarily, contains every 4-mer in the decomposition, a protein it is derived from must also contain every 4-mer, and must therefore be in every one of these sets. The set intersection of these sets is taken, which usually results in a small number (< 10) of candidate proteins. From these, true matches are determined by ensuring that the peptide appears in the protein sequence, via regular-expression search.
- With the set of progenitor proteins known, the protein-to-gene lookup table is used to get the matching set of genes.