Skip to main content

Translates and transcribes an arbitrary genetic sequence, generates FASTA-formatted files, and interfaces with BLAST databases to identify genetic and protein sequences.

Project description

PyPI version Actions Status Downloads License

Installation

The following command installs Codons in a command prompt/terminal environment:

pip install codons

__init__

The data environment, in a Python IDE, is defined:

import codons
cd = codons.Codons(sequence = None, codons_table = 'standard', amino_acids_form = 'full_name', hyphenated = None, verbose = False, printing = True)
  • sequence str: specifies the genetic sequence that will be processed through subsequent functions, which can alternatively be provided in each function ad hoc.

  • codons_table str: specifies the framework for translating codons into amino acids, where the standard translation table is used by default.

  • amino_acids_form str: specifies whether the amino acid full_name, three_letter, or one_letter nomenclature will be used in the protein sequence.

  • hyphenated bool: specifies whether amino acid residues of the protein sequence are delimited by hyphens, where None defaults to True for amino_acids_for = full_name and amino_acids_for = three_letter and False for amino_acids_for = one_letter.

  • verbose & printing bool: specifies whether troubleshooting information or MW results will be printed, respectively.

transcribe()

A genetic sequence is converted from DNA -> RNA, or RNA -> DNA, where the directionality of the conversion is automatically listed in the FASTA description:

transcribed_sequence = cd.transcribe(sequence = None, description = '')
  • sequence str: The genetic seqeuence that will be transcribed. The sequence is case-insensitive, and can even possess line numbers or column-spaces, which the code ignores. The absence of a passed sequence executes the sequence that is loaded into the Codons object.

  • description str: A description of the genetic seqeuence that will be added to the FASTA-formatted output of the function.

Returns: transcribed_sequence str: The translated sequence as a single string.

translate()

A genetic sequence is translated into a FASTA-formatted sequence of amino acids for each protein that is coded by the genetic code:

proteins = cd.translate(sequence = None, description = '')
  • sequence str: The genetic seqeuence, of either DNA or RNA, that will be parsed and translated into a protein sequence. The sequence is case-insensitive, and can even possess line numbers or column-spaces, which the code ignores. The absence of a passed sequence executes the sequence that is loaded into the Codons object.

  • description str: A description of the genetic seqeuence that will be added to the FASTA-formatted output of the function.

Returns: proteins dict: A dictionary of the proteins, where the key is the one-letter protein sequence and the value is the mass of the respective sequence.

make_fasta()

A simple function that returns, and optionally exports, a FASTA-formatted file from the parameterized description and sequence:

fasta_file = cd.make_fasta(sequence, description = 'sequence', export_path = None):
  • sequence str: The genetic or protein seqeuence that will constitute the FASTA file.

  • description str: A description of the seqeuence that will be the first line of the FASTA file.

  • export_path str: The path to which the FASTA file will be exported, where None specifies that the file will not be exported.

Returns: fasta_file str: The FASTA-formatted file, based upon the parameterized sequence and description.

blast_protein()

A protein sequence or a FASTA-formatted file of protein sequences is searched in through the BLAST database of the NIH for information about the protein(s):

cd.blast_protein(sequence = None, database = 'nr', )
  • sequence str: The genetic seqeuence, of either DNA or RNA, that will be parsed and translated into a protein sequence. The sequence is case-insensitive, and can even possess line numbers or column-spaces, which the code ignores. The absence of a passed sequence executes the sequence that is loaded into the Codons object.

  • database str: The BLAST database that will be searched for the protein sequence. Permissible options include: nr, refseq_select, refseq_protein, landmark, swissprot, pataa, pdb, env_nr, tsa_nr.

  • export_name & export_directory str: The name of the folder and directory to which the scraped BLAST data will be saved in a file: nucleotide_blast_results.xml. The None values enable the code to construct a unique folder name that describes the contents and saves it to the current working directory.

blast_nucleotide()

A genetic sequence is translated into a FASTA-formatted sequence of amino acids for each protein that is coded by the genetic code:

cd.translate(sequence = None, database= 'nt', export_name = None, export_directory = None)
  • sequence str: The genetic seqeuence, of either DNA or RNA, that will be parsed and translated into a protein sequence. The sequence is case-insensitive, and can even possess line numbers or column-spaces, which the code ignores. The absence of a passed sequence executes the sequence that is loaded into the Codons object.

  • database str: The BLAST database that will be searched for the nucleotide sequence. Permissible options include: nr, nt, refseq_select, refseq_rna, refseq_representative_genomes, wgs, refseq_genomes, est, SRA, TSA, HTGS, pat, pdb, RefSeq_Gene, gss, dbsts.

  • export_name & export_directory str: The name of the folder and directory to which the scraped BLAST data will be saved in a file: protein_blast_results.xml. The None values enable the code to construct a unique folder name that describes the contents and saves it to the current working directory.

export()

The genetic sequence and any corresponding protein or nucleotide content from the aforementioned functions, which reside in the Codons object, are exported:

cd.export(export_name = None, export_directory = None)
  • export_name str: optionally specifies a name for the folder of exported content, where None enables the code to design a unique folder name for simulation and descriptive tags of the contents.

  • export_directory str: optionally specifies a path to where the content will be exported, where None selects the current working directory.

Accessible content

The Codons object retains numerous components that are accessible to the user:

  • proteins list: A list of the protein sequences that are generated by the parameterized genetic sequence.

  • protein_fasta & gene_fasta str: Assembled FASTA-formatted files for the translated proteins from a parameterized genetic sequence and for a genetic sequence, respectively.

  • protein_mass dict: A collection of the protein sequences and their respective masses, in a key-value pairing, that were discovered in the translate() function.

  • transcribed_sequence & sequence str: The transcribed genetic sequence from the transcription() function, and the genetical sequence that is used in any of the Codons functions.

  • amino_acid_synonyms dict: The synonyms for each amino acid, with keys of the full amino acid name.

  • codons_table & changed_codons dict: The translation table between genetic codons and amion acid residues, which is accessed with case-insensitivity, and the translation conversions that were changed based upon the user’s specification.

  • missed_codons dict: A collections of the codons that were parsed yet never matched with a codons_table key.

  • paths & parameters dict: Collections of the paths and parameters are are defined for the simulation.

  • export_path str: The complete export path for the Codons contents.

  • protein_blast_results & nucleotide_blast_results str: The BLAST search results for the passed proteins and nucleotides, respectively.

Execution

Codons is executed through the following sequence of the aforementioned functions, which is exemplified in the example Notebook of our GitHub repository:

import codons
cd = codons.Codons(sequence = None, codons_table = 'standard', amino_acids_form = 'full_name', hyphenated = None, verbose = False, printing = True)
# < Codons function(s) >
cd.export(export_name = None, export_directory = None)

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

Codons-0.0.4.tar.gz (10.9 kB view hashes)

Uploaded Source

Supported by

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