Skip to content

Ferny730JR/SeqFile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT GitHub release GitHub issues CMake >=3.9.0

SeqFile

SeqFile is a lightweight, zlib-inspired C library for efficient reading and processing of FASTA, FASTQ, and raw sequence file formats.

It is designed to be fast, minimal, thread-safe, and easy to integrate into C projects. Whether you're building a full-scale bioinformatics pipeline or a small utility, SeqFile provides a clean and efficient interface to handle sequence data, mimicking the <stdio.h> and <zlib.h> API's for familiarity.

Table of Contents

  1. Installation
  2. Usage
  3. Examples
  4. License
  5. Contact

Installation

Dependencies

Quick Start

Once you have downloaded the repository and the required dependencies, run the following commands:

cd seqfile
cmake -B build && cmake --build build
cmake --build build --target install

Note: This will install the library into the default system path, which is typically /usr/local/lib and /usr/local/include.

User-dir Installation

One issue you might encounter with the previous installation is that it might require root privileges. In case you do not have root privileges in your computer, you can specify the installation location to a place you have write access to by using the -DCMAKE_INSTALL_PREFIX flag as such:

cmake -DCMAKE_INSTALL_PREFIX=/your/preferred/path -B build && cmake --build build
cmake --build build --target install

Testng

Once you have setup the project, you can run the tests to ensure SeqFile is working as intended.

./build/test/test-seqf

Usage

To use SeqFile in your own project, include the SeqFile header as follows in your own code:

#include <seqfile.h>

Then, you have two options to link the library:

1. Manual Linking

Compile your C file with:

gcc your_program.c -lseqf -o your_program

2. Using CMake

You can add SeqFile to your CMake-based project like this:

add_subdirectory(seqfile)
target_link_libraries(your_target PRIVATE seqf_static)  # for static linking
# or
target_link_libraries(your_target PRIVATE seqf_shared)  # for shared linking

Examples

Here's a basic example of how to use the library:

#include <seqfile.h>
#include <stdio.h> // for printf
#include <stdlib.h> // for malloc and size_t

int
main(void)
{
	/* Open a fasta file for reading */
	SeqFile sfp = seqfopen("example.fasta", "a");
	if(sfp == NULL) {
		printf("seqfopen: %s", seqfstrerror(seqferrno));
		return 1;
	}

	/* Allocate space for buffer to read into */
	size_t bufsize = 1000;
	char *buffer = malloc(bufsize * sizeof *buffer);

	/* Read all sequences in the file */
	while(seqfgets(sfp, buffer, bufsize) != NULL) {
		printf("sequence: '%s'\n", buffer);
	}

	/* Close the SeqFile handle to release resources */
	if(seqfclose(sfp) != 0) {
		printf("seqfclose: %s\n", seqfstrerror(seqferrno));
		return 1;
	}

	/* Success */
	return 0;
}

License

This project is licensed under the MIT License.

Contact

For bug reports, feature requests, or general questions:

About

A lightweight, zlib-inspired C library for efficient reading and processing of FASTA, FASTQ, and other sequence file formats.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors