evolbioinfo / goalign

Goalign is a set of command line tools and an API to manipulate multiple sequence alignments. It is implemented in Go language.
GNU General Public License v2.0
73 stars 8 forks source link
alignment fasta nexus phylip phylip-alignment phylogeny

Goalign

build Anaconda-Server Badge Docker hub downloads DOI:10.1093/nargab/lqab075

Goalign Logo

Goalign is a set of command line tools to manipulate multiple alignments. It is implemented in Go language.

Goalign aims to handle multiple alignments in Phylip, Fasta, Nexus, and Clustal formats, through several basic commands. Each command may print result (an alignment for example) in the standard output, and thus can be piped to the standard input of the next goalign command.

Input files may be local or remote files:

Gzipped input files (.gz extension) are supported, as well as XZ files (.xz extension) and BZipped files (.bz[2] extension).

Note:

TO manipulate phylogenetic trees, See also Gotree.

Reference

If you use Gotree or Goalign, please cite:

Frédéric Lemoine, Olivier Gascuel

Gotree/Goalign: toolkit and Go API to facilitate the development of phylogenetic workflows,

NAR Genomics and Bioinformatics, Volume 3, Issue 3, September 2021, lqab075, doi

Installation

Easy way: Binaries

You can download ready to run binaries for the latest release in the release section. Binaries are available for MacOS, Linux, and Windows (32 and 64 bits).

Once downloaded, you can just run the executable without any other downloads.

Docker

Goalign Docker image is accessible from docker hub. You may use it as following:

# Display goalign help
docker run -v $PWD:$PWD -w $PWD -i -t evolbioinfo/goalign:v0.2.6 -h

Singularity

Goalign docker image is usable from singularity . You may use it as following:

# Pull image from docker hub
singularity pull docker://evolbioinfo/goalign:v0.2.6
# Display goalign help
./goalign-v0.2.6.simg -h

Conda

Goalign is also available on bioconda. Just type:

conda install -c bioconda goalign

From sources

To build goalign, you must first download and install Go on your system ($1.21.6$).

Then you just have to type :

git clone git@github.com:evolbioinfo/goalign.git
cd goalign
make && make install
# or go get . && go build .
# or go get . && go install .

The goalign executable should be located in the current folder (or the $GOPATH/bin).

To test the executable:

./test.sh

Auto completion

goalign uses cobra, and therefore proposes a command to generate auto completion scripts:

gotree completion -h

Usage

You may go to the doc for a more detailed documentation of the commands.

List of commands

Goalign commandline examples

Goalign api usage examples

import ( "fmt" "os"

"github.com/evolbioinfo/goalign/align"
"github.com/evolbioinfo/goalign/io/fasta"
"github.com/evolbioinfo/goalign/io/phylip"

)

func main() { var err error var f *os.File var align align.Alignment

f, err = os.Open("f.phy")
if err != nil {
    panic(err)
}
if align, err = phylip.NewParser(f).Parse(); err != nil {
    panic(err)
} else {
    fmt.Println(fasta.WriteSequences(align))
}

}


* Parse a Phylip multi alignments file and export it in Fasta
```go
package main

import (
    "fmt"
    "os"

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

func main() {
    var f *os.File
    var aligns chan align.Alignment
    var err error

    f, err = os.Open("f.phy")
    if err != nil {
        panic(err)
    }
    aligns = make(chan align.Alignment, 15)
    if err = phylip.NewParser(f).ParseMultiple(aligns); err != nil {
        panic(err)
    } else {
        for al := range aligns {
            fmt.Println(fasta.WriteSequences(al))
        }
    }
}

import ( "fmt" "os"

"github.com/evolbioinfo/goalign/align"
"github.com/evolbioinfo/goalign/io/fasta"
"github.com/evolbioinfo/goalign/io/nexus"

)

func main() { var f *os.File var align align.Alignment var err error

f, err = os.Open("f.fasta")
if err != nil {
    panic(err)
}
if align, err = fasta.NewParser(f).Parse(); err != nil {
    panic(err)
} else {
    fmt.Println(nexus.WriteAlignment(align))
}

}

* Parse a Fasta file and export it in Phylip
```go
package main

import (
    "fmt"
    "os"

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

func main() {
    var f *os.File
    var align align.Alignment
    var err error

    f, err = os.Open("f.fasta")
    if err != nil {
        panic(err)
    }
    if align, err = fasta.NewParser(f).Parse(); err != nil {
        panic(err)
    } else {
        fmt.Println(phylip.WriteAlignment(align, false))
    }
}

Other functions are described in the godoc.