Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 739 Bytes

consensus.md

File metadata and controls

46 lines (36 loc) · 739 Bytes

Goalign: toolkit and api for alignment manipulation

API

consensus

package main

import (
	"bufio"
	"fmt"
	"io"

	"github.com/evolbioinfo/goalign/align"
	"github.com/evolbioinfo/goalign/io/fasta"
	"github.com/evolbioinfo/goalign/io/utils"
)

func main() {
	var fi io.Closer
	var r *bufio.Reader
	var err error
	var al, cons align.Alignment
	var ignoreGaps bool = false
	var ignoreNs bool = false

	/* Get reader (plain text or gzip) */
	fi, r, err = utils.GetReader("align.fa")
	if err != nil {
		panic(err)
	}

	/* Parse Fasta */
	al, err = fasta.NewParser(r).Parse()
	if err != nil {
		panic(err)
	}
	fi.Close()

	/* Consensus */
	cons = al.Consensus(ignoreGaps, ignoreNs)

	fmt.Println(fasta.WriteAlignment(cons))
}