Using ModPipe from your own programs

It is possible to use ModPipe from your own programs. This can be done in two ways. The first is simply to call the ModPipe script (modpipe) from your own scripts, providing them with the necessary configuration files and command line options, and then parsing any output. The second is to import the ModPipe Python or Perl libraries into your own Python or Perl programs. This can be done simply by adding lib/python or lib/perl to your Python or Perl search path, respectively. For example, to read in a ModPipe models file and print the ID and DOPE score of each model (using the modpipe.serialize module), you can use a Python script similar to the following (adjust /modpipe/location/ to the directory you have ModPipe installed in):

import sys
sys.path.append('/modpipe/location/lib/python')

import modpipe.serialize

fh = open('d18b74a08d8b83e15835daaf76471976FCGHGNVV.mod')

for model in modpipe.serialize.read_models_file(fh):
    print "Model: %s; DOPE score %f" % (model.id, model.score.dope)

The equivalent Perl script looks like:

use lib '/modpipe/location/lib/perl';

use PLLib::Utils;
use MPLib::Serialize;

my $fh = OpenFile('d18b74a08d8b83e15835daaf76471976FCGHGNVV.mod');
my $models = ReadModelsFile($fh);
close($fh);

for my $model (@$models) {
  printf "Model: %s; DOPE score %f\n", $model->id, $model->score->dope;
}