Skip to main content

ProteinNetPy 1.0.1

DOI Documentation Status

A python library for working with ProteinNet text data, allowing you to easily load, stream and filter data, map functions across records and produce TensorFlow datasets. For details of the dataset see the ProteinNet Bioinformatics paper. Documentation for all functions of the module is available here.

Install

pip install proteinnetpy

Or install the development version from Github:

pip install git+https://github.com:allydunham/proteinnetpy

Requirements

  • Python 3
  • Numpy
  • Biopython
  • TensorFlow (if using the datasets module)

Basic Usage

The main object used in ProteinNetPy is the ProteinNetRecord, which allows access to the various record fields and methods for common manipulations, such as calculating a one-hot sequence representation or residue distance matrix. It also supports most applicable operations like len, str etc. While the parser module contains a generator to parse files, it is generally easier to use the ProteinNetDataset class from the data module:

from proteinnetpy.data import ProteinNetDataset
data = ProteinNetDataset(path="path/to/proteinnet")

This class includes a preload argument, which determines if the dataset is loaded into memory or streamed. It also supports filtering using the filter_func argument, which is passed a function that returns truthy values for a record to determine if it is kept in the dataset. A range of common filters are included in the data module, as well as combine_filters(), which can applies all passed filters to each record.

Once a dataset has been loaded it can be iterated over to process data. The ProteinNetMap class creates map objects that map a function over the dataset, including options to stream the map on each iteration or pre-calculate results. They have a generate method that creates a generator object yielding the output of the function. The LabeledFunction class is provided to create functions annotated with output types and shapes, used for automatically creating TensorFlow datasets. The mutation module provides some example functions that return mutated records.

The following example code shows a typical simple usage, creating a streamed TensorFlow dataset from ProteinNet data:

from proteinnetpy import data
from proteinnetpy import tfdataset

class MapFunction(data.LabeledFunction):
    """
    Example ProteinNetMap function outputting a one-hot sequence and contact graph input data
    and multiple alignment PSSM labels
    """
    def __init__(self):
        self.output_shapes = (([None, 20], [None, None]), [None, 20])
        self.output_types = (('float32', 'float32'), 'int32')

    def __call__(self, record):
        return (record.get_one_hot_sequence().T, record.distance_matrix()), record.evolutionary.T

filter_func = data.make_length_filter(min_length=32, max_length=2000)
data = data.ProteinNetDataset(path="path/to/proteinnet", preload=False)
pn_map = data.ProteinNetMap(data, map=MapFunction(), static=False, filter_errors=True)

tf_dataset = tfdataset.proteinnet_tf_dataset(pn_map, batch_size=100, prefetch=400, shuffle_buffer=200)

Many more functions, arguments and uses are available, with detailed descriptions currently found in docstrings. Full documentation will be generated from these for a future release.

Scripts

The package also provides convenience scripts for processing ProteinNet datasets:

  • add_angles_to_proteinnet - Add extra fields to a ProteinNet file with φ, ψ and χ backbone/torsion angles
  • proteinnet_to_fasta - Extract a fasta file with the sequences from a ProteinNet file
  • filter_proteinnet - Filter a ProteinNet file to include/exclude records from a list of IDs

Detailed usage instructions for each can be found using the -h argument.

Metadata

Release files for proteinnetpy 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for proteinnetpy 1.0.1
File Size Uploaded Provenance
proteinnetpy-1.0.1.tar.gz 25.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for proteinnetpy 1.0.1
File Interpreter ABI Platform
proteinnetpy-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 76.2 kB

Release files / proteinnetpy-1.0.1.tar.gz

Download URL proteinnetpy-1.0.1.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d4650759a019e859c55119dd5c98b18df499e389f54cec49087221660d12ab4e
BLAKE2b-256 checksum
How to use checksums
c716ab8ee1e8bb5954629c11ce035da23416e1a1e95c64502693e555486f6058
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / proteinnetpy-1.0.1-py3-none-any.whl

Download URL proteinnetpy-1.0.1-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
161de26b65e2f1ff5c836a1c11705cf4272260752a9be08ec45eb01d45b3fc2f
BLAKE2b-256 checksum
How to use checksums
707499a1c7ac64de66e856b35540659d849f04654cbd7b5b145961069ce428f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Security for proteinnetpy 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page