SW#
All Files Functions Variables Typedefs Macros
Typedefs | Functions
chain.h File Reference

Provides object for storing named sequnces. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct Chain Chain
 Chain object used for storing named sequnces. More...
 

Functions

ChainchainCreate (char *name, int nameLen, char *string, int stringLen)
 Chain object constructor. More...
 
void chainDelete (Chain *chain)
 Chain destructor. More...
 
char chainGetChar (Chain *chain, int index)
 Chain char getter. More...
 
char chainGetCode (Chain *chain, int index)
 Chain code getter. More...
 
int chainGetLength (Chain *chain)
 Chain length getter. More...
 
const char * chainGetName (Chain *chain)
 Chain name getter. More...
 
ChainchainCreateView (Chain *chain, int start, int end, int reverse)
 Creates a view to the chain object. More...
 
void chainCopyCodes (Chain *chain, char *dest)
 Copies chain code to a buffer. More...
 
ChainchainDeserialize (char *bytes)
 Chain deserialization method. More...
 
void chainSerialize (char **bytes, int *bytesLen, Chain *chain)
 Chain serialization method. More...
 

Detailed Description

Provides object for storing named sequnces.

Typedef Documentation

typedef struct Chain Chain

Chain object used for storing named sequnces.

Chain object is created from a named sequences and is used for alignment. Chain characters are coded with scorerEncode(char) function. Chain object provides view method for creating subchains and reverse subchains in constant time. On that behalf every chain object uses approximately 2 times more memory than the input sequence.

Function Documentation

void chainCopyCodes ( Chain chain,
char *  dest 
)

Copies chain code to a buffer.

Destination buffer should be allocated and its length should be greater or equal to chain length.

Parameters
chainchain object
destpointer to the destination buffer
Chain* chainCreate ( char *  name,
int  nameLen,
char *  string,
int  stringLen 
)

Chain object constructor.

Method constructs the chain object with a given name and character sequence. All given data is copied. Any non-alphabetical characters in the sequence are ignored. All characters in the sequence are changed to uppercase.

Parameters
namechain name
nameLenchain name length
stringchain characters
stringLenchain characters length
Returns
chain object
Chain* chainCreateView ( Chain chain,
int  start,
int  end,
int  reverse 
)

Creates a view to the chain object.

Method creates a subchain from the input chain. It doesn't copy the data since the original chain object is immutable. However the top parent chain object (one created via the constructor), should not be deleted before the views are deleted. Both the start and end indexes shoulde be greater than 1 and less than the chain length.

Parameters
chainchain object
startstart index, inclusive
endend index, inclusive
reversebool, 1 if the view should be reverse 0 otherwise
Returns
chain view
void chainDelete ( Chain chain)

Chain destructor.

Parameters
chainchain object
Chain* chainDeserialize ( char *  bytes)

Chain deserialization method.

Method deserializes chain object from a byte buffer.

Parameters
bytesbyte buffer
Returns
chain object
char chainGetChar ( Chain chain,
int  index 
)

Chain char getter.

Method retrives the char from the index position. Index must be greater or equal to zero and less than chain length.

Parameters
chainchain object
indexchain char index
Returns
chain char
char chainGetCode ( Chain chain,
int  index 
)

Chain code getter.

Method retrives the code from the index position. Index must be greater or equal to zero and less than chain length. Chain caracter is coded with the scorerEncode(char) function.

Parameters
chainchain object
indexchain code index
Returns
chain code
int chainGetLength ( Chain chain)

Chain length getter.

Parameters
chainchain object
Returns
length
const char* chainGetName ( Chain chain)

Chain name getter.

Parameters
chainchain object
Returns
name
void chainSerialize ( char **  bytes,
int *  bytesLen,
Chain chain 
)

Chain serialization method.

Method serializes chain object to a byte buffer.

Parameters
bytesoutput byte buffer
bytesLenoutput byte buffer length
chainchain object