Skip to main content

FaSTPACE: A Fast and Scalable Tool for Peptide Alignment and Consensus Extraction

Project description

FaSTPACE: A Fast and Scalable Tool for Peptide Alignment and Consensus Extraction

FaSTPACE (Fast and Scalable Tool for Peptide Alignment and Consensus Extraction) is a Python package implemented in C++ programming language.

Table of contents

Description

FaSTPACE algorithm

The core of the algorithm produces a refined global similarity matrix from which these outputs are produced. A global similarity matrix is a probabilistic representation of the similarity of the peptide to all other peptides in the dataset. The method consists of three steps: initiation, refinement and post-processing of the global similarity matrix.

Usage

Install the package:

pip install fastpace

Import functions:

from fastpace import run_motif_discovery, rerun_motif_discovery

run_motif_discovery(peptides, weights=None, refine=1, normalization_factor=-1)

Calculate per residue similarity scores, align peptides, and extract putative motifs.

Parameters:

  • peptides (list): List of strings of standard sequence letters representing peptides in the dataset. It should contain 2 or more peptides. No sequence with less than 2 letters or longer than 32 characters is allowed.
  • weights (list, optional, default=None): List of positive numbers representing weights. The number of weights must be equal to the number of peptides. If not provided, each peptide is assigned a weight of 1.
  • refine (int, optional, default=1): Flag with 0 or 1. (0 means return the results after the initiation step, 1 means doing the refinement step)
  • normalization_factor (float, optional, default=-1): The dataset size is corrected to be equal to this number in order to compare different datasets with different sizes. It must be equal to or greater than 1. By default, -1 means to use the dataset size with no normalization.

Returns:

  • Dictionary: The dictionary object returned contains information about the discovered motif, alignment results, and similarity scores for each peptide. Below is a breakdown of the key elements in the output:
    .
    ├── Refinement Information:
    │   └── refinement_iterations: The number of refinement iterations performed.
    ├── Consensus Motif Information:
    │   ├── best_motif: The best consensus motif represented as a regular expression.
    │   ├── best_motif_p_val: P-value associated with the best consensus motif.
    │   ├── best_motif_significance: Significance level of the best consensus motif.
    │   ├── best_motif_num_matches: Number of matches found for the best consensus motif.
    │   └── best_motif_coverage: Coverage percentage of the best consensus motif.
    ├── Alignment Information: 
    │   ├── template: The template sequence used for alignment.
    │   └── aligned_sequences: A dictionary mapping each input sequence to its aligned counterpart.
    └── Peptide-specific Information:
        For each peptide in the dataset, the following information is provided:
        ├──  similarity_matrix: A matrix of peptide's global similarity scores.
        ├──  similarity_motif: The motif represented as a regular expression extracted from the peptide's global similarity matrix.
        ├──  similarity_p_val: P-value associated with the similarity motif.
        ├──  similarity_significance: Significance level of the similarity motif.
        ├──  similarity_num_matches: Number of matches found for the similarity motif.
        ├──  similarity_coverage: Coverage percentage of the similarity motif.
        ├──  similarity_score: Cumulative similarity score for the peptide.
        ├──  matched_motif: The motif with the best p-value that matches the peptide.
        ├──  matched_p_val: P-value associated with the matched motif.
        ├──  matched_significance: Significance level of the matched motif.
        ├──  matched_num_matches: Number of matches found for the matched motif.
        ├──  matched_coverage: Coverage percentage of the matched motif.
        └──  alignment_score: Alignment score for the peptide on the template sequence.

Example:

peptides = ['TSPDGGTTFEHLWSSL', 'SPEVFQHIWDFLEQPI', 'CPVDPFEAQWAALENK', 'EPPLSQETFSDLWKLL', 'APELDPFEAQWAALEG']
run_motif_discovery(peptides, refine=0)

Output:

{
  "refinement_iterations": 0,
  "consensus": {
    "best_motif": ".*F...W..L.*",
    "best_motif_p_val": 4.030701364259203e-12,
    "best_motif_significance": 6.449063505442609e-09,
    "best_motif_num_matches": 5,
    "best_motif_coverage": 1.0
  },
  "alignment": {
    "template": "TSPDGGTTFEHLWSSL",
    "aligned_sequences": {
      "TSPDGGTTFEHLWSSL": "TSPDGGTTFEHLWSSL----",
      "SPEVFQHIWDFLEQPI": "----SPEVFQHIWDFLEQPI",
      "CPVDPFEAQWAALENK": "---CPVDPFEAQWAALENK-",
      "EPPLSQETFSDLWKLL": "EPPLSQETFSDLWKLL----",
      "APELDPFEAQWAALEG": "--APELDPFEAQWAALEG--"
    }
  },
  "peptides": {
    "TSPDGGTTFEHLWSSL": {
      "similarity_matrix": {
        // ...
      },
      // ...
    },
    "SPEVFQHIWDFLEQPI": {
      // ...
    },
    // ...
  }
}

Example with weighting:

peptides = ['TSPDGGTTFEHLWSSL', 'SPEVFQHIWDFLEQPI', 'CPVDPFEAQWAALENK', 'EPPLSQETFSDLWKLL', 'APELDPFEAQWAALEG']
weights = [1, 2, 4, 1.5, 0.1]
run_motif_discovery(peptides, weights)

Output:

{
   "refinement_iterations":30,
   "consensus":{
      "best_motif":".*F...W..L.*",
      "best_motif_p_val":4.030701364259203e-12,
      "best_motif_significance":2.8327562517915794e-09,
      "best_motif_num_matches":5,
      "best_motif_coverage":1.0
   },
   "alignment":{
      "template":"APELDPFEAQWAALEG",
      "aligned_sequences":{
         "TSPDGGTTFEHLWSSL":"TSPDGGTTFEHLWSSL----",
         "SPEVFQHIWDFLEQPI":"----SPEVFQHIWDFLEQPI",
         "CPVDPFEAQWAALENK":"---CPVDPFEAQWAALENK-",
         "EPPLSQETFSDLWKLL":"EPPLSQETFSDLWKLL----",
         "APELDPFEAQWAALEG":"--APELDPFEAQWAALEG--"
      }
   },
  "peptides": {
    "TSPDGGTTFEHLWSSL": {
      "similarity_matrix": {
        // ...
      },
      // ...
    },
    "SPEVFQHIWDFLEQPI": {
      // ...
    },
    // ...
  }
}

rerun_motif_discovery(original_peptides, masked_peptides, weights=None)

Calculate per residue similarity scores and extract putative motifs after masking previously extracted motifs.

Parameters:

  • original_peptides (list): List of the original peptides before masking.
  • masked_peptides (list): List of the masked peptides. The masked positions should be substituted with the character X. The number of masked peptides must be equal to the number of original peptides.
  • weights (list, optional, default=None): List of positive weights.

Returns:

  • Dictionary: The dictionary object returned contains information about the discovered motif, alignment results, and similarity scores for each peptide. The output has the same format as the previous function.

Example:

peptides = ['TSPDGGTTFEHLWSSL', 'SPEVFQHIWDFLEQPI', 'CPVDPFEAQWAALENK', 'EPPLSQETFSDLWKLL', 'APELDPFEAQWAALEG']
masked_peptides = ['TSPDGGTTXXXXXSSL', 'SPEVXXXXXDFLEQPI', 'CPVDPXXXXXAALENK', 'EPPLSQETXXXXXKLL', 'APELDPXXXXXAALEG']
rerun_motif_discovery(peptides, masked_peptides)

Output:

{
  "refinement_iterations": 23,
  "consensus": {
    "best_motif": ".*D........LE.*",
    "best_motif_p_val": 0.00033767412104890706,
    "best_motif_significance": 0.41746722746831066,
    "best_motif_num_matches": 2,
    "best_motif_coverage": 0.4
  },
  "alignment": {
    "template": "CPVDPXXXXXAALENK",
    "aligned_sequences": {
      "TSPDGGTTXXXXXSSL": "TSPDGGTTXXXXXSSL----",
      "SPEVXXXXXDFLEQPI": "----SPEVXXXXXDFLEQPI",
      "CPVDPXXXXXAALENK": "---CPVDPXXXXXAALENK-",
      "EPPLSQETXXXXXKLL": "EPPLSQETXXXXXKLL----",
      "APELDPXXXXXAALEG": "--APELDPXXXXXAALEG--"
    }
  },
  "peptides": {
    "TSPDGGTTXXXXXSSL": {
      "similarity_matrix": {
        // ...
      },
      // ...
    },
    "SPEVXXXXXDFLEQPI": {
      // ...
    },
    "CPVDPXXXXXAALENK": {
      // ...
    },
    "EPPLSQETXXXXXKLL": {
      // ...
    },
    "APELDPXXXXXAALEG": {
      // ...
    }
  }
}

Fasta File Processing Script

A script is designed to process fasta files, align peptides, perform motif discovery, and generate sequence logos. It utilizes the fastpace module for motif discovery and the logomaker library for creating sequence logos.

Prerequisites

  • Before using this script, ensure that you have the required Python libraries installed. You can install them using the following command:
pip install fastpace pandas matplotlib seaborn logomaker
  • Clone the repository (to download the script):
git clone https://github.com/hkotb/fastpace.git
cd fastpace/test/

Run the script

python fastpace_cmd.py --input_file input.fasta --output_file output.fasta [--draw_logo] [--sequence SEQUENCE] [--num_reruns NUM_RERUNS] [--refine REFINE]

Command-line Arguments

  • --input_file: The path to the input fasta file. (Required)
  • --output_file: The path to the output fasta file. (Required)
  • --draw_logo: Draw sequence logo of the best peptide or the peptide passed by --sequence. (Optional)
  • --sequence: Draw sequence logo of this peptide. (Optional)
  • --num_reruns: Number of times to rerun the algorithm before returning the results. (Default: 1)
  • --refine: Flag to run the refinement. (Default: 1)

Examples

Basic Usage

python fastpace_cmd.py --input_file input.fasta --output_file output.fasta

Drawing Sequence Logo

python fastpace_cmd.py --input_file input.fasta --output_file output.fasta --draw_logo

Drawing Sequence Logo for a Specific Peptide

python fastpace_cmd.py --input_file input.fasta --output_file output.fasta --draw_logo --sequence GATCGATCG

Running Multiple Reruns

python fastpace_cmd.py --input_file input.fasta --output_file output.fasta --num_reruns 3

Running without Refinement

python fastpace_cmd.py --input_file input.fasta --output_file output.fasta --refine 0

Output

The script generates an output fasta file of the aligned peptides, a JSON file containing the motif discovery results, and a PNG file containing the sequence logo (if --draw_logo is specified).

  • Output Fasta File: output.fasta
  • JSON Result File: output.json
  • Sequence Logo File: output.png

Development

We recommend that you clone the repository and install it as a development package with:

python setup.py develop

To generate a distribution archive from your machine:

python -m build

To distribute binary Python extensions as wheels on Linux:

docker pull quay.io/pypa/manylinux2014_x86_64
docker run --rm -e PLAT=manylinux2014_x86_64 -v `pwd`:/io quay.io/pypa/manylinux2014_x86_64  /io/build-wheels.sh

License

This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.

Reference

If you find the pipeline useful in your research, we ask that you cite our paper:

Coming soon.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastpace-1.0.1.tar.gz (371.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fastpace-1.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.6 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fastpace-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.6 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fastpace-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.6 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fastpace-1.0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (61.2 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

fastpace-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (313.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

fastpace-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (312.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

fastpace-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (312.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

fastpace-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (311.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

fastpace-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (314.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

fastpace-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.6 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

fastpace-1.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (310.4 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

Details for the file fastpace-1.0.1.tar.gz.

File metadata

  • Download URL: fastpace-1.0.1.tar.gz
  • Upload date:
  • Size: 371.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.5

File hashes

Hashes for fastpace-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6e1e5fa5d08185c6f5c809b3657aaece86f5d022e2fd32745032a39c65e0a028
MD5 96dc688e3c2273ce7e6bbb6f8e592cd2
BLAKE2b-256 9cab5c17351d83a69b6d8ac80ff1345a630fd449afc1ab10b4df7056682e3721

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2daf917c19c3aabf8c786cf0a140660b4485d7078a8901125dcfdf362f81b309
MD5 a294f3d522c3eff5bd238c63eafc5310
BLAKE2b-256 017a8a17646d89c6d5556403e291eceb94863a757d05ea79c6aa3b3e3f53e2d7

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6fe41b3b373d64ddbb9692b95b36f02926f296a6fc61ad4f59f710d9cd3ed158
MD5 fc3866c099070caa6109481c32baf69c
BLAKE2b-256 03b25173d39c234fca18a87af306335108988d42bcf1ed30538addf970c00f28

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1757972733c30158e7416b6ae117c473849c9e7cb0227cbb76810bc10fed1370
MD5 c46f636d162739e3df6cc63714f2baaa
BLAKE2b-256 1980221af12e20f6dd9e04bf3ad8bc7d50ca2778f938c56c2db7990b47cb7e3b

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b21d5ad7a23f93eaf3e434480e4bdebfe5b19a005c7e90195c3cc112523c3312
MD5 a55146c12357e350b7ee57f347e39a10
BLAKE2b-256 c63d5ada6596a1cf63adb6c54bfe96c7d3f1173e45f460ead82b6cac1f7f5da8

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f9e8338ce60df9d6aa9844e87aeb23831cbb75a10bf073c7b25bb49d579f7ff
MD5 1eaeab1b4aeb6d00c08b549d575c507a
BLAKE2b-256 f810181942515993165b2157a5da6dfef809613d0450e6418fbdeb0500e57c06

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 252942cba7c7e3370fe8f9ed55c111b4a77546136af69ddffcae99e82168e3b8
MD5 f21e271a861e3fb9ad0b8d5b5ffcaec1
BLAKE2b-256 e6f63ed7264fa1c5f90de1361b2e16f657c03bc5eaa3d71ea3b57f2f14ee89b0

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6152ddd91f24a7efb69f331a1580b826585a9bbf917a91a21fd4b96a0e046c80
MD5 69e657066dba5568bf0679056ff512a1
BLAKE2b-256 6544a3fe393a69b221a7e82e538987cf55faefe2d00583c82d228ef4ea452f65

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 77b66a655968f6235accc90477a4fcef1081b2385e0794f11f74f2e7e6f5c7cd
MD5 cfb483d3e7143566257c77300fce11d5
BLAKE2b-256 7c3aeea2ac640dddb4df7ad9d21cc9c806031d851d2b61c3dfc1cad460341adb

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3252724fce7ee75164efb6d8cfec067053e90b8f1b21da3a1257ea53e39673a
MD5 64bb95bdce51b9d11a135fac8c872cef
BLAKE2b-256 8cbd258f3ec7f9421491d40e032872cb2eb985c3826998adf2c025a85f499efd

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 36ac4983d630a27ed9bd093ecb373a0dbdf9395b3be8b294c05b92e102e3ea12
MD5 8cea67cc2a64a88436a067deacd810e0
BLAKE2b-256 17bdba120d313a87a8e41e8c6419530b3b5d76bdcf5fceca96c72b836c7687bb

See more details on using hashes here.

File details

Details for the file fastpace-1.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fastpace-1.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 93c73de34cb681bf3daae59cc940e118b4a8a0fec532f63f344b7c27fc380b44
MD5 85b40fbc112152c06f90d8beddf1695e
BLAKE2b-256 960596d939b629a6e7940719b89312784492c762d1d3967184e032c04dd6eee8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page