yat  0.21pre
Classes | Public Member Functions | List of all members
theplu::yat::omic::Fasta Class Reference

wrapper class around struct faidx_t in libhts More...

#include <yat/omic/Fasta.h>

Classes

class  Sequence
 

Public Member Functions

 Fasta (const std::string &fn)
 
bool present (const std::string &name) const
 
std::string name (size_t i) const
 
int nseq (void) const
 
int sequence_length (const std::string &name) const
 
Sequence sequence (const std::string &chr) const
 
Sequence sequence (const std::string &chr, int beg, int end) const
 

Detailed Description

wrapper class around struct faidx_t in libhts

Class handling a fasta file. Class assumes the fasta file has an index file created by e.g. 'samtools faidx'.

Since
New in yat 0.14

Constructor & Destructor Documentation

◆ Fasta()

theplu::yat::omic::Fasta::Fasta ( const std::string &  fn)

Tries to open index for fasta file fn. It is assumed that the index file is called fn + ".fai". If open fails, constructor tries to create an index file from fasta file fn (see fai_build in htslib). If that also fails, an exception is thrown.

Exceptions
utility::runtime_errorif open fails

Member Function Documentation

◆ name()

std::string theplu::yat::omic::Fasta::name ( size_t  i) const
Returns
name of sequence i

◆ nseq()

int theplu::yat::omic::Fasta::nseq ( void  ) const
Returns
number of sequences

◆ present()

bool theplu::yat::omic::Fasta::present ( const std::string &  name) const
Returns
true if there exist a sequence called name

◆ sequence() [1/2]

Sequence theplu::yat::omic::Fasta::sequence ( const std::string &  chr) const
Returns
entire sequence from sequence chr

◆ sequence() [2/2]

Sequence theplu::yat::omic::Fasta::sequence ( const std::string &  chr,
int  beg,
int  end 
) const
Parameters
chrsequence name
begbeginning position (0-based)
endend position (0-based)
Returns
sub-sequence of chr starting at beg and with last base end (length of sequence is end-begin+1).

◆ sequence_length()

int theplu::yat::omic::Fasta::sequence_length ( const std::string &  name) const
Returns
length of sequence with name name
Exceptions
utility::runtime_errorif there is no sequence named name

The documentation for this class was generated from the following file:

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14