Skip to main content

Neural networks for amino acid sequences

Project description

Build Status


Neural networks for amino acid sequences

Predictor API

Sequence and model construction can both be handled for you by pepnet’s Predictor:

from pepnet import Predictor, SequenceInput, NumericInput, Output
predictor = Predictor(
        SequenceInput(length=4, name="x1", variable_length=True),
        NumericInput(dim=30, name="x2")],
    outputs=[Output(name="y", dim=1, activation="sigmoid")],
sequences = ["ACAD", "ACAA", "ACA"]
vectors = np.random.normal(10, 100, (3, 30))
y = numpy.array([0, 1, 0]){"x1": sequences, "x2": vectors}, y)
y_pred = predictor.predict({"x1": sequences, "x2": vectors})["y"]

Convolutional sequence filtering

This model takes an amino acid sequence (of up to length 50) and applies to it two layers of 9mer convolution with 3x maxpooling and 2x downsampling in between. The second layer’s activations are then pooled across all sequence positions (using both mean and max pooling) and passed to a single dense output node called “y”.

peptide =
predictor = Predictor(
        length=50, name="peptide", encoding="index", variable_length=True,
    outputs=[Output(name="y", dim=1, activation="sigmoid")])

Manual index encoding of peptides

Represent every amino acid with a number between 1-21 (0 is reserved for padding)

from pepnet.encoder import Encoder
encoder = Encoder()
X_index = encoder.encode_index_array(["SYF", "GLYCI"], max_peptide_length=9)

Manual one-hot encoding of peptides

Represent every amino acid with a binary vector where only one entry is 1 and the rest are 0.

from pepnet.encoder import Encoder
encoder = Encoder()
X_binary = encoder.encode_onehot(["SYF", "GLYCI"], max_peptide_length=9)

FOFE encoding of peptides

Implementation of FOFE encoding from A Fixed-Size Encoding Method for Variable-Length Sequences with its Application to Neural Network Language Models

from pepnet.encoder import Encoder
encoder = Encoder()
X_binary = encoder.encode_FOFE(["SYF", "GLYCI"], bidirectional=True)

Example network

Schematic of a convolutional model: image1

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

pepnet-0.3.2.tar.gz (21.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page