An easy FASTA object handler, reader, writer and translator for small to medium size projects without dependencies.

Overview

miniFASTA

An easy FASTA object handler, reader, writer and translator for small to medium size projects without dependencies.

Test Badge Download Badge

Installation

Using pip / pip3:

pip install miniFasta

Or by source:

git clone [email protected]:not-a-feature/miniFASTA.git
cd miniFASTA
pip3 install .

How to use

miniFASTA offers easy to use functions for fasta handling. The five main parts are:

  • fasta_object()
  • read_fasta()
  • write_fasta()
  • translate_seq()
  • reverse_comp()

fasta_object()

The core component of miniFASTA is the fasta_object(). This object represents an entry in a FASTA file and consists of a head and body.

Atlantic dolphin", "CGGCCTTCTATCTTCTTC") print(fo.head) # >Atlantic dolphin print(fo.body) # CGGCCTTCTATCTTCTTC">
from miniFasta import miniFasta as fasta
fo = fasta.fasta_object(">Atlantic dolphin", "CGGCCTTCTATCTTCTTC")
print(fo.head) # >Atlantic dolphin
print(fo.body) # CGGCCTTCTATCTTCTTC

Following functions are defined on a fasta_object():

str()

str(fo) # will return:
# >Atlantic dolphin
# CGGCCTTCTATCTTCTTC

len()

len(fo) # will return 18, the length of the body

==

Same Body", "CGGCCTTCTATCTTCTTC") print(fo == fo_b) # True fo_c = fasta.fasta_object(">Different Body", "ZZZZAGCTAG") print(fo == fo_c) # False">
print(fo == fo) # True

fo_b = fasta.fasta_object(">Same Body", "CGGCCTTCTATCTTCTTC")
print(fo == fo_b) # True

fo_c = fasta.fasta_object(">Different Body", "ZZZZAGCTAG")
print(fo == fo_c) # False

toAmino(translation_dict)

Translates the body to an amino-acid sequence. See tranlate_seq() for more details.

fo.toAmino() 
print(fo.body) # Will return RPSIFF
d = {"CCG": "Z", "CTT": "A" ...}
fo.toAmino(d) 
print(fo.body) # Will return ZA...

toRevComp(complement_dict)

Converts the body to its reverse comlement. See reverse_comp() for more details.

fo.toRevComp() 
print(fo.body) # Will return GAAGAAGATAGAAGGCCG

Reading FASTA files

read_fasta() is a basic fasta reader. It reads a fasta-style file and returns a list of fasta_objects. The entries are usually casted to upper case letters. Set read_fasta("path.fasta", upper=False) to disable casting.

fos = fasta.read_fasta("dolphin.fasta") # List of fasta entries
fos = fasta.read_fasta("cat.fasta", upper=False)

Writing FASTA files

write_fasta() is a basic fasta reader. It takes a single or a list of fasta_objects and writes it to the given path.

The file is usually overwritten. Set write_fasta(fo, "path.fasta", mode="a") to append file.

fos = fasta.read_fasta("dolphin.fasta") # List of fasta entries
fasta.write_fasta(fos, "new.fasta")

Sequence translation

translate_seq() translates a sequence starting at position 0. Unless translation_dict is provided, the standart bacterial code is used. If the codon was not found, it will be replaced by an ~. Tailing bases that do not fit into a codon will be ignored.

fasta.translate_seq("CGGCCTTCTATCTTCTTC") # Will return RPSIFF

d = {"CGG": "Z", "CTT": "A"}
fasta.translate_seq("CGGCTT", d) # Will return ZA.

Reverse Complement

reverse_comp() converts a sequence to its reverse comlement. Unless complement_dict is provided, the standart complement is used. If no complement was found, the nucleotide remains unchanged.

fasta.reverse_comp("CGGCCTTCTATCTTCTTC") # Will return GAAGAAGATAGAAGGCCG

d = {"C": "Z", "T": "Y"}
fasta.reverse_comp("TC", d) # Will return ZY
You might also like...
Data Structures and Algorithms Python - Practice data structures and algorithms in python with few small projects

Data Structures and Algorithms All the essential resources and template code nee

Master Duel Card Translator Project

Master Duel Card Translator Project A tool for translating card effects in Yu-Gi-Oh! Master Duel. Quick Start (for Chinese version only) Download the

Python 3.9.4 Graphics and Compute Shader Framework and Primitives with no external module dependencies
Python 3.9.4 Graphics and Compute Shader Framework and Primitives with no external module dependencies

pyshader Python 3.9.4 Graphics and Compute Shader Framework and Primitives with no external module dependencies Fully programmable shader model (even

Beginner Projects A couple of beginner projects here

Beginner Projects A couple of beginner projects here, listed from easiest to hardest :) selector.py: simply a random selector to tell me who to faceti

Small projects for python beginners.

Python Mini Projects For Beginners I recently started doing the #100DaysOfCode Challenge in Python. I've used Python before, but I had switched to JS

poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions

poetry2nix poetry2nix turns Poetry projects into Nix derivations without the need to actually write Nix expressions. It does so by parsing pyproject.t

edgetest is a tox-inspired python library that will loop through your project's dependencies, and check if your project is compatible with the latest version of each dependency

Bleeding edge dependency testing Full Documentation edgetest is a tox-inspired python library that will loop through your project's dependencies, and

Feature engineering library that helps you keep track of feature dependencies, documentation and schema

Feature engineering library that helps you keep track of feature dependencies, documentation and schema

Identify unused production dependencies and avoid a bloated virtual environment.

creosote Identify unused production dependencies and avoid a bloated virtual environment. Quickstart # Install creosote in separate virtual environmen

Comments
Releases(v3.0.2)
  • v3.0.2(Nov 8, 2022)

    What's Changed

    • Add support of py3.11 and update gh actions by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/22

    Full Changelog: https://github.com/not-a-feature/miniFASTA/compare/v3.0.1...v3.0.2

    Source code(tar.gz)
    Source code(zip)
  • v3.0.1(Oct 12, 2022)

    What's Changed

    • Update README.md by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/18
    • Merge by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/19
    • switch to iterator by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/20
    • Add dataclass decorator by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/21

    Full Changelog: https://github.com/not-a-feature/miniFASTA/compare/v2.4.1...v3.0.1

    Source code(tar.gz)
    Source code(zip)
  • v2.4.1(Sep 24, 2022)

    What's Changed

    • add py3.7 support by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/17

    Full Changelog: https://github.com/not-a-feature/miniFASTA/compare/v2.4.0...v2.4.1

    Source code(tar.gz)
    Source code(zip)
  • v2.4.0(Jul 4, 2022)

    What's Changed

    • Update README.md by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/15
    • add option to read only the body by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/16

    Full Changelog: https://github.com/not-a-feature/miniFASTA/compare/v2.3.2...v2.4.0

    Source code(tar.gz)
    Source code(zip)
  • v2.3.2(Mar 11, 2022)

    What's Changed

    • Black code formatting by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/14

    Full Changelog: https://github.com/not-a-feature/miniFASTA/compare/v2.3.1...v2.3.2

    Source code(tar.gz)
    Source code(zip)
  • v2.3.1(Feb 23, 2022)

    What's Changed

    • Add type information and update readme by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/13

    Full Changelog: https://github.com/not-a-feature/miniFASTA/compare/v2.3.0...v2.3.1

    Source code(tar.gz)
    Source code(zip)
  • v2.3.0(Feb 23, 2022)

    What's Changed

    • Dev by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/11
    • add iter and getter methods by @not-a-feature in https://github.com/not-a-feature/miniFASTA/pull/12

    Full Changelog: https://github.com/not-a-feature/miniFASTA/compare/v2.2.1...v2.3.0

    Source code(tar.gz)
    Source code(zip)
Owner
Jules Kreuer
Jules Kreuer
Aevsploit İçin Destekde Bulun Papara: 1427113016

Aevsploit İçin Destekde Bulun Papara: 1427113016 Toolu Geliştirmek İçin Fikirlerinizi Bekliyorum Telegram

9 Jun 07, 2022
Run CodeServer on Google Colab using Inlets in less than 60 secs using your own domain.

Inlets Colab Run CodeServer on Colab using Inlets in less than 60 secs using your own domain. Features Optimized for Inlets/InletsPro Use your own Cus

2 Dec 30, 2021
Prop-based map editor for the Apex Legends mod, R5Reloaded

R5R Map Editor A tool to build maps out of props in the Apex Legends mod, R5Reloaded Instuctions Install R5R Download this program Get the prop spawne

7 Dec 16, 2022
Easily Generate Revolut Business Cards

RevBusinessCardGen Easily Generate Revolut Business Cards Prerequisites Before you begin, ensure you have met the following requirements: You have ins

Younes™ 35 Dec 14, 2022
Pyrmanent - Make all your classes permanent in a flash 💾

Pyrmanent A base class to make your Python classes permanent in a flash. Features Easy to use. Great compatibility. No database needed. Ask for new fe

Sergio Abad 4 Jan 07, 2022
tool to automate exploitation of android degubg bridge vulnerability

DISCLAIMER DISCLAIMER: ANY MALICIOUS USE OF THE CONTENTS FROM THIS ARTICLE WILL NOT HOLD THE AUTHOR RESPONSIBLE HE CONTENTS ARE SOLELY FOR EDUCATIONAL

6 Feb 12, 2022
- Auto join teams teams ( from calendar invite )

Auto Join Teams Meetings Requirements: Python 3.7 or higher Latest Google Chrome This script automatically logins to your account and joins the meetin

Prajin Khadka 10 Aug 20, 2022
A simple tool made in Python language

Simple tool Uma simples ferramenta feita 100% em linguagem Python 💻 Requisitos: Python3 instalado em seu dispositivo Clonagem e acesso 📳 git clone h

josh washington 4 Dec 07, 2021
Turn a raspberry pi into a Bluetooth Midi device

PiBluetoothMidSetup This will change serveral system wide packages/configurations Do not run this on your primary machine or anything you don't know h

MyLab6 40 Sep 19, 2022
In this project, we'll be creating a virtual personal assistant for ourselves using our favorite programming language

In this project, we'll be creating a virtual personal assistant for ourselves using our favorite programming language, Python. We can perform several offline as well as online operations using the bo

Ashutosh Krishna 188 Jan 03, 2023
Contain the customization I made for my Linux rice.

dotfiles Contain the customization I made for my Linux rice. Credit and Respect Polybar Autohide Fulltime Rofi by adi1090x (only include my personal r

sora 3 Apr 04, 2022
Python client SDK designed to simplify integrations by automating key generation and certificate enrollment using Venafi machine identity services.

This open source project is community-supported. To report a problem or share an idea, use Issues; and if you have a suggestion for fixing the issue,

Venafi, Inc. 13 Sep 27, 2022
A collection of Python library code for building Python applications.

Abseil Python Common Libraries This repository is a collection of Python library code for building Python applications. The code is collected from Goo

Abseil 2k Jan 07, 2023
A simple script for generating screenshots with Vapoursynth

Vapoursynth-Screenshots A simple script for generating screenshots with Vapoursynth. About I'm lazy, and hate changing variables for each batch of scr

7 Dec 31, 2022
Python Control Systems Library

The Python Control Systems Library is a Python module that implements basic operations for analysis and design of feedback control systems.

Control Systems Library for Python 1.3k Jan 06, 2023
Sublime Text 2/3 style auto completion for ST4

Hippie Autocompletion Sublime Text 2/3 style auto completion for ST4: cycle through words, do not show popup. Simply hit Tab to insert completion, hit

Alexander Schepanovski 20 May 19, 2022
Fork of pathlib aiming to support the full stdlib Python API.

pathlib2 Fork of pathlib aiming to support the full stdlib Python API. The old pathlib module on bitbucket is in bugfix-only mode. The goal of pathlib

Jazzband 73 Dec 23, 2022
Materials for the Introduction in Python , Linux , Git and Github

This repository contains all the materials of the presentation on the introduction of python, linux, git and Github.

AMMI 3 Aug 28, 2022
Platform Tree for Xiaomi Redmi Note 7/7S (lavender)

The Xiaomi Redmi Note 7 (codenamed "lavender") is a mid-range smartphone from Xiaomi announced in January 2019. Device specifications Device Xiaomi Re

MUHAMAD KHOIRON 2 Dec 20, 2021
A script that convert WiiU BotW mods to Switch

UltimateBoTWConverter A script that convert WiiU BotW mods to Switch. It uses every resource I could find under the sun that allows for conversion, wi

11 Nov 08, 2022