Skip to content

A simple C file reader for P7 profile HMM files generated by HMMER3 and other tools

License

Notifications You must be signed in to change notification settings

TravisWheelerLab/P7HmmReader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

P7HmmReader

A simple C file reader for P7 profile HMM files generated by HMMER3 and other tools.

Prerequisites

The following is required to build and use this software

  • a C compiler, like GCC
  • Make

Building the library

after cloning the library, you can build the library using the makefile

make

this will create a /build directory in the project directory. Inside, you'll find /build/include which will contain the public header necessary to use the library. The build directory also includes /build/lib, which will contain both the static library file (libP7HmmReader.a), as well as the dynamic library (libP7HmmReader.so on linux, or libP7HmmReader.dylib on mac).

Building and Installing the library

To install the dynamic library to the default location, you can use the makefile's install target after building like above.

make
make install

This will attempt to install the library to /usr/local, which requires sudo privilages. To install locally and skip needing sudo, you can specify where the library will be installed with the PREFIX variable:

make install PREFIX=~/.local/

the above example would copy the static library file into ~/.local/lib, and the public header into ~/.local/include.

If P7HmmReader is installed to a non-default location, you may need to set environmental variables to allow your software to find the project .so and .h files at runtime.

export LD_LIBRARY_PATH=~/.local/lib
export LD_RUN_PATH=~/.local/include

Remember to include these exports into your .bashrc file if you want to maintain them across terminal sessions.

P7HmmReader Quick Start Guide

The full public API can be found in the header src/P7HmmReader.h. This header contains the structs that will be used to store the profile hmm data, and the prototype for the public functions. If you are familiar with the HMMER3 spec for hmm files, the naming conventions of the data in the P7Hmm struct should look familiar.

To generate a P7PhmmList struct, use the readP7Hmm function.

enum P7HmmReturnCode readP7Hmm(const char *const fileSrc, struct P7HmmList *phmmList);

'fileSrc' is the location of the profile hmm file to read. 'phmmList' is a pointer to a phmmList struct to fill with data from the hmm file.

As such, here is an example of how you might use the library. This example loads the profile hmm file, and prints all the match emission scores for the first profile hmm in the file.

  struct P7HmmList phmmList;
  char *hmmFileSrc = "path/to/hmm/file.hmm";

  enum P7HmmReturnCode returnCode = readP7Hmm(hmmFileSrc, &phmmList);
  if(returnCode == p7HmmAllocationFailure){
    printf("failed to allocate memory for the phmm List\n");
    exit(1);
  }
  else if(returnCode == p7HmmFormatError){
    printf("failed to read phmm file due to formatting error\n");
    exit(2);
  }

  //print the match emissions for the first profile hmm in the list
  for(uint32_t nodeIndex = 0; nodeIndex < phmmList.phmms[0].header.modelLength; nodeIndex++){
    printf("node %u", nodeIndex);
    for(uint32_t symbol = 0; symbol < p7HmmGetAlphabetCardinality(phmmList.phmms[0]); symbol++){
      printf("  %f", p7HmmGetMatchEmissionScore(phmmList.phmms[0], nodeIndex, symbolIndex));
    }
    printf("\n");
  }

  //dealloc the phmmList when finished
  p7HmmListDealloc(&phmmList)

About

A simple C file reader for P7 profile HMM files generated by HMMER3 and other tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published