Skip to content

Perl bindings to C code of ntthal from primer3 suite

License

Notifications You must be signed in to change notification settings

reineckef/Ntthal-XS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ntthal-XS

This Perl module uses Inline::C to bind the ntthal alignment from the primer3 code and make it available as a Perl subroutine call. It uses an object-oriented Mouse interface.

The main motivation to do this was speed of execution, especially to reduce overhead generated by process creation (fork) and passing of sequences, retrieval of results via shell process communication. See BENCHMARK for results.

INSTALLATION

To install this module, clone the code and run the following commands:

perl Makefile.PL
make
make test
make install

Alternatively, you can download the latest release and run:

cpanm Ntthal-XS-#.#.#.tar.gz

Here, the # signs are placeholders for the version number.

The package will also install a demo/driver script named ntthal_xs.pl, which should be executable after installation. The purpose is to test the functionality and serve as a template for own code.

SYNOPSIS

use Ntthal::XS;
my $NT = Ntthal::XS->new();

# tm will accept only one sequence
print $NT->tm('TAATACGACTCACTATAGGG');    # 44.5215658215416

# change parameters
$NT->type('END1');
$NT->dv(0.8);

# ntthal will use two sequences (different strands!)
my $hybrid = $NT->ntthal( 'CCCGAAAAGTGCCACCTG', 'CAGGTGGCATTTTTTCGGG' );
# $hybrid = {
#   dG => -13335.3624649896,          # { 0}
#   dH => -132500,                    # { 1}
#   dna_conc => 50,                   # { 2}
#   dntp => 0.8,                      # { 3}
#   dS => -384.216145526392,          # { 4}
#   duplex0 => "        G-         ", # { 5}
#   duplex1 => "CCCGAAAA  TGCCACCTG", # { 6}
#   duplex2 => "GGGCTTTT  ACGGTGGAC", # { 7}
#   duplex3 => "        TT         ", # { 8}
#   dv => 0.8,                        # { 9}
#   maxLoop => 8,                     # {10}
#   mv => 50,                         # {11}
#   s1 => "CCCGAAAAGTGCCACCTG",       # {12}
#   s2 => "CAGGTGGCATTTTTTCGGG",      # {13}
#   t => 42.0422986972263,            # {14}
#   temp => 37,                       # {15}
#   type => "END1",                   # {16}
# }

# compare to the ntthal command line output
#
#  ntthal -a END1 -dv 0.8 -s1 CCCGAAAAGTGCCACCTG -s2 CAGGTGGCATTTTTTCGGG
#  Calculated thermodynamical parameters for dimer:	dS = -384.216	dH = -132500	dG = -13335.4	t = 42.0423
#  SEQ	        G-         
#  SEQ	CCCGAAAA  TGCCACCTG
#  STR	GGGCTTTT  ACGGTGGAC
#  STR	        TT         

BENCHMARK

Here, a comparison is shown for the traditional ntthal command line call, a newer version that does not read all parameter files at every call (it uses pre-populated lists) named ntthal_new and the xs version implemented here. Note: The underlying algorithm was not changed, only the overhead calling it from Perl was reduced.

Benchmark: timing 5000 iterations of ntthal, ntthal_new, xs...
    ntthal: 16 wallclock secs ( 0.18 usr  1.82 sys +  7.84 cusr  7.28 csys = 17.12 CPU) @ 292.06/s (n=5000)
ntthal_new: 10 wallclock secs ( 0.16 usr  1.22 sys +  5.09 cusr  3.38 csys =  9.85 CPU) @ 507.61/s (n=5000)
        xs:  2 wallclock secs ( 2.37 usr +  0.00 sys =  2.37 CPU) @ 2109.70/s (n=5000)
             Rate     ntthal ntthal_new         xs
ntthal      292/s         --       -42%       -86%
ntthal_new  508/s        74%         --       -76%
xs         2110/s       622%       316%         --

That is about a 4-fold improvement on my system.

LICENSE AND COPYRIGHT

Copyright (C) 2019 Frank Reinecke ([email protected])

This program is released under the following license: AGPL3, see LICENSE.

About

Perl bindings to C code of ntthal from primer3 suite

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages