Skip to content

This script converts a FASTA file to NEXUS format, reading sequences, generating the NEXUS header and MATRIX, and printing the output to stdout.

License

Notifications You must be signed in to change notification settings

Rendrick27/FASTA2NEX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FASTA to NEXUS Converter

Description

This repository contains a script and associated unit tests for converting DNA sequence data from FASTA format to NEXUS format. The script fasta2nex.py consists of functions to read FASTA files, generate NEXUS headers, and convert the entire content into a NEXUS formatted output.

Features fasta2nex.py

  • read_fasta(file_path): Reads a FASTA file and returns a dictionary of sequences;
  • generate_nexus_header(sequences): Generates a NEXUS header and MATRIX block from a dictionary of sequences;
  • fasta_to_nexus(file_path): Converts a FASTA file to NEXUS format and prints the output to STDOUT.

Features script_test.py

This script contains unit tests for the functions provided in fasta2nex.py. It ensures that each function works correctly by checking them against expected outputs using the unittest framework.

Requirements

Installation

# Download the project
wget https://github.com/Rendrick27/FASTA2NEX/archive/refs/heads/main.zip

# Unzip the folder
unzip main.zip

Usage

cd main.zip

Then, run the following command:

python fasta2nex.py input.fasta
  • Replace input.fasta with the path to your FASTA file.

  • The NEXUS output will be printed to the console

To run the script_test.py:

python -m unittest script_test.py

Motivation

  • Practical Application: To provide a simple and efficient way to convert DNA sequence data from the widely used FASTA format to the NEXUS format, which is commonly used in phylogenetic analysis;

  • Educational: This script was developed as a homework assignment for UC Análise de Sequências Biológicas.

Credits

Rendrick Carreira - 201901365

Ravi Silva - 202100191

Francisca Figueiredo - 202200580

License

GPLv3

About

This script converts a FASTA file to NEXUS format, reading sequences, generating the NEXUS header and MATRIX, and printing the output to stdout.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages