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
Ice Skating Simulator for Winter and Christmas [yay]

Ice Skating Simulator for Winter and Christmas [yay]

1 Aug 21, 2022
It is a personal assistant chatbot, capable to perform many tasks same as Google Assistant plus more extra features...

PersonalAssistant It is an Personal Assistant, capable to perform many tasks with some unique features, that you haven'e seen yet.... Features / Tasks

Roshan Kumar 95 Dec 21, 2022
Домашние задания, выполненные на 3ем семестре РТУ МИРЭА, по дисциплине

ДЗ по курсу "Конфигурационное управление" в РТУ МИРЭА Описание В данном репозитории находятся домашние задания, выполненные на 3ем семестре РТУ МИРЭА,

Semyon Esaev 4 Dec 22, 2022
Object-data mapper and advanced query manager for non relational databases

Object data mapper and advanced query manager for non relational databases. The data is owned by different, configurable back-end databases and it is

Luca Sbardella 121 Aug 11, 2022
this is a basic python project that I made using python

this is a basic python project that I made using python. This project is only for practice because my python skills are still newbie.

Elvira Firmansyah 2 Dec 14, 2022
Medical appointments No-Show classifier

Medical Appointments No-shows Why do 20% of patients miss their scheduled appointments? A person makes a doctor appointment, receives all the instruct

4 Apr 20, 2022
a url shortener with fastapi and tortoise-orm

fastapi-tortoise-orm-url-shortener a url shortener with fastapi and tortoise-orm

19 Aug 12, 2022
pyreports is a python library that allows you to create complex report from various sources

pyreports pyreports is a python library that allows you to create complex reports from various sources such as databases, text files, ldap, etc. and p

Matteo Guadrini aka GU 78 Dec 13, 2022
Helps compare between New and Old Tax Regime.

Income-Tax-Calculator Helps compare between New and Old Tax Regime. Sample Console Input/Output

2 Jan 10, 2022
Python solutions to Codeforces problems

CodeForces This repository is dedicated to my Python solutions for CodeForces problems. Feel free to copy, contribute and/or comment. If you find any

Shukur Sabzaliev 15 Dec 20, 2022
Service for working with open data of the State Duma of the Russian Federation

Сервис для работы с открытыми данными Госдумы РФ Исходные данные из API Госдумы РФ извлекаются с помощью Apache Nifi и приземляются в хранилище Clickh

Aleksandr Sergeenko 2 Feb 14, 2022
Sodium is a general purpose programming language which is instruction-oriented

Sodium is a general purpose programming language which is instruction-oriented (a new programming concept that we are developing and devising)

Satin Wuker 22 Jan 11, 2022
This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator

Late-Bound Arguments This package tries to emulate the behaviour of syntax proposed in PEP 671 via a decorator. Usage Mention the names of the argumen

Shakya Majumdar 0 Feb 06, 2022
CalHacks 8 Repo: Megha Jain, Gaurav Bhatnagar, Howard Meng, Vibha Tantry

CalHacks8 CalHacks 8 Repo: Megha Jain, Gaurav Bhatnagar, Howard Meng, Vibha Tantry Setup FE Install React Native via Expo, run App.js. Backend Create

0 Aug 20, 2022
Proyecto - Análisis de texto de eventos históricos

Acceder al código desde Google Colab para poder ver de manera adecuada todas las visualizaciones y poder interactuar con ellas. Link de acceso: https:

1 Jan 31, 2022
Project Guide for ASAM OpenX standards

ASAM Project Guide Important This guide is a work in progress and subject to change! Hosted version available at: ASAM Project Guide (Link) Includes:

ASAM e.V. 2 Mar 17, 2022
A basic DIY-project made using Python and MySQL

Banking-Using-Python-MySQL This is a basic DIY-project made using Python and MySQL. Pre-Requisite needed:-- MySQL command Line:- creating a database

ABHISHEK 0 Jul 03, 2022
Anonfiles files leaker via keyword.

Anonfiles files leaker via keyword

Trac3D1y 6 Nov 23, 2022
Animations made using manim-ce

ManimCE Animations Animations made using manim-ce The code turned out to be a bit complicated than expected.. It can be greatly simplified, will work

sparshg 17 Jan 06, 2023
Replite - An embeddable REPL powered by JupyterLite

replite An embeddable REPL, powered by JupyterLite. Usage To embed the code cons

Jeremy Tuloup 47 Nov 09, 2022