Skip to main content

Simple python to lazily one-hot encode fasta files using multiple processes.

Project description

travis sonar_quality sonar_maintainability sonar_coverage Maintainability pip

Simple python to lazily one-hot encode fasta files using multiple processes, either single bases or considering arbitrary kmers.

Installation

Simply run:

pip installed fasta_one_hot_encoder

Examples

Bases

Bases

One-hot encode to bases.

from fasta_one_hot_encoder import FastaOneHotEncoder

encoder = FastaOneHotEncoder(
    nucleotides = "acgt",
    lower = True,
    sparse = False,
    handle_unknown="ignore"
)
path = "test_data/my_test_fasta.fa"
encoder.transform_to_df(path, verbose=True).to_csv(
    "my_result.csv"
)

Obtained results should look like:

  a c g t
0 0 0 1 0
1 0 1 0 0
2 0 1 0 0

Kmers

Kmers

One-hot encode to kmers of given length.

from fasta_one_hot_encoder import FastaOneHotEncoder

encoder = FastaOneHotEncoder(
    nucleotides = "acgt",
    kmers_length=2,
    lower = True,
    sparse = False,
    handle_unknown="ignore"
)
path = "test_data/my_test_fasta.fa"
encoder.transform_to_df(path, verbose=True).to_csv(
    "my_result.csv"
)

Obtained results should look like:

  aa ac ag at ca cc cg ct ga gc gg gt ta tc tg tt
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

Project details


Download files

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

Files for fasta-one-hot-encoder, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size fasta_one_hot_encoder-1.1.0.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

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