Code Monkey home page Code Monkey logo

gotoh's Introduction

Gotoh

Short C implementation (around 500 lines of codes + comments) of the Gotoh algorithm, also known as the Needleman-Wunsch algorithm with affine gap penalties.

Features

  • C99-compliant, only uses stdio.h, stdlib.h, string.h, and ctype.h
  • basic command-line interface
  • read FASTA files
  • read NCBI/EMBOSS scoring matrix files
  • exact same results as EMBOSS Needle
  • initial values in the dynamic programming arrays can be loaded from files

Due to the last point, the program can be used for experimenting with different scoring schemes, for example:

  • gap opening penalties depending on the residues surrounding the gap
  • substitution scores depending on the matched residues and their positions in the sequence
  • doing something else than biological sequence alignment, such as dynamic time warping

Usage

Compile with this command:

gcc -std=c99 gotoh.c main.c -o align

Then type ./align and read the help message.

Basic example showing how to use the code:

gth_Seq sequenceX = gth_read_fasta("first_sequence.fasta");
gth_Seq sequenceY = gth_read_fasta("second_sequence.fasta");
gth_Sub matrix = gth_read_matrix("BLOSUM62");
int gapopen=10, gapextend=1, endopen=0, endextend=0;

gth_Arr array = gth_init(sequenceX.len, sequenceY.len);
gth_set_sub(array, sequenceX.res, sequenceY.res, matrix.score);
gth_set_gap(array, gapopen, gapextend, endopen, endextend);
int score = gth_align(array);

printf("Score: %d\n", score);
gth_putseq(stdout, sequenceX.res, array.gapX);
printf("\n");
gth_putseq(stdout, sequenceY.res, array.gapY);
printf("\n");

gth_free(array);
free(sequenceX.res);
free(sequenceY.res);

Reference

Durbin, Eddy, Krogh, Mitchison. Biological Sequence Analysis, Cambridge University Press, 1998.

gotoh's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.