fasta

package
v0.0.0-...-897f0b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

The fasta package is designed to provide a suite of functions for reading, writing and manipulating Fasta sequence files. This library can be imported into other go projects to allow for simplified use and creation of Fasta files. The Query functions also provide the ability to retrieve new sequence data in fasta format from the National Center for Biotechnology Information (NCBI) databases by providing a slice of unique sequence ids. Importing this library provides the following specalized data structures and methods:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryToFile

func QueryToFile(accession []string, output string) error

This function can be used in lieu of the Query function in instances where the data are not required in memory, they can then be written directly to a file (this is more efficient as the data does not need to be processed into the Fasta structure and the string can be written straight to the file). The function takes two argumens. The first argument is a slice of strings where each of the strings is an NCBI accession number. The second argument is a string containing the desired output file name to which the sequences obtained in the NCBI query will be written.

Types

type Fasta

type Fasta []Seq

A slice of Seq types []Seq This structure represents a fasta file for the library, it is a set of Seq structures. The library's input/output functionality allows for efficient reading and writing of files in standard fasta format

func Query

func Query(accession []string) Fasta

This function takes a slice of strings as an argument, where each of the strings is an NCBI accession number. It will query NCBI for these accession numbers, and return a Fasta type instance containing the a Seq struct corresponding to each of the accession numbers.

func Read

func Read(filename string) Fasta

This function takes one argument, a string specifying the name of a fasta file. It returns an Fasta object with the sequence information from the file.

func (*Fasta) AddItem

func (fa *Fasta) AddItem(item Seq)

add a seq struct instance to the fasta struct

func (*Fasta) Sort

func (fa *Fasta) Sort()

This method can be called on a Fasta type instance to sort the underlying sequences alphabetically, by the Name fields of the constituent Seqs. The Fasta will be modified in place (this is a pointer reciever method).

func (Fasta) String

func (fa Fasta) String() string

Return the Fasta file in fasta format

func (Fasta) Summary

func (fa Fasta) Summary() []summaryDat

This method should be used with nucleotide Fasta structures only. Calling this method returns a slice of structs with three fields: the name, the length and the percent GC content of the sequences in the Fasta

func (Fasta) Write

func (fa Fasta) Write(file ...string)

This method can be called on an existing Fasta type. It takes one argument, a filename (path optional) to which the Fasta will be written. The output is in standard Fasta format, with a header line prefaced by a '>' character and a sequence section with 60 characters of sequence per line.

func (Fasta) WriteSummary

func (fa Fasta) WriteSummary(file ...string)

This method has the same functionality as the Summary method, but instead of providing the output slice with the summary data in memory, it writes the summary directly to the file specified as a string in the method call.

type Seq

type Seq struct {
	Name     string
	Sequence string
}

A struct with two fields, Name and Sequence to represent the two parts of a fasta file entry.

func (Seq) String

func (sq Seq) String() string

return the sequence in fasta format when called

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL