HackaMol-X-Vina

 view release on metacpan or  search on metacpan

lib/HackaMol/X/Vina.pm  view on Meta::CPAN

sub dock {
  my $self      = shift;
  my $num_modes = shift;
  $self->num_modes($num_modes) if defined($num_modes);
  $self->map_input;
  return $self->map_output;
}

sub dock_mol {
  # want this to return configurations of the molecule
  my $self      = shift;
  my $num_modes = shift;
  $self->num_modes($num_modes) if defined($num_modes);
  $self->map_input; 
  local $CWD = $self->scratch if ( $self->has_scratch );
  my @bes = $self->map_output; # this is fragile... broken if map_out changed...
  my $mol = HackaMol -> new(hush_read => 1)
                     -> read_file_mol($self->out_fn->stringify);
  $mol->push_score(@bes);
  return ($mol);
}

sub write_input {
    my $self = shift;
    my $input;
    $input .= sprintf( "%-15s = %-55s\n", 'out', $self->out_fn->stringify );
    $input .= sprintf( "%-15s = %-55s\n", 'log', $self->log_fn->stringify )
      if $self->has_log_fn;
    foreach my $cond (
        qw(receptor ligand cpu num_modes energy_range exhaustiveness seed))
    {
        my $condition = "has_$cond";
        $input .= sprintf( "%-15s = %-55s\n", $cond, $self->$cond )
          if $self->$condition;
    }
    foreach my $metric (qw(center_x center_y center_z size_x size_y size_z)) {
        $input .= sprintf( "%-15s = %-55s\n", $metric, $self->$metric );
    }
    $self->in_fn->spew($input);
    return ($input);
}

__PACKAGE__->meta->make_immutable;

1;

__END__

=pod

=head1 NAME

HackaMol::X::Vina - HackaMol extension for running Autodock Vina

=head1 VERSION

version 0.012

=head1 SYNOPSIS

  use Modern::Perl;
  use HackaMol;
  use HackaMol::X::Vina;
  use Math::Vector::Real;

  my $receptor = "receptor.pdbqt";
  my $ligand   = "lig.pdbqt",
  my $rmol     = HackaMol -> new( hush_read=>1 ) -> read_file_mol( $receptor );
  my $lmol     = HackaMol -> new( hush_read=>1 ) -> read_file_mol( $ligand );
  my $fh = $lmol->print_pdb("lig_out.pdb");

  my @centers = map  {$_ -> xyz}
                grep {$_ -> name    eq "OH" }
                grep {$_ -> resname eq "TYR"} $rmol -> all_atoms;

  foreach my $center ( @centers ){

      my $vina = HackaMol::X::Vina -> new(
          receptor       => $receptor,
          ligand         => $ligand,
          center         => $center,
          size           => V( 20, 20, 20 ),
          cpu            => 4,
          exhaustiveness => 12,
          exe            => '~/bin/vina',
          scratch        => 'tmp',
      );

      my $mol = $vina->dock_mol(3); # fill mol with 3 binding configurations

      printf ("Score: %6.1f\n", $mol->get_score($_) ) foreach (0 .. $mol->tmax); 

      $mol->print_pdb_ts([0 .. $mol->tmax], $fh); 

    }

    $_->segid("hgca") foreach $rmol->all_atoms; #for vmd rendering cartoons.. etc
    $rmol->print_pdb("receptor.pdb");

=head1 DESCRIPTION

HackaMol::X::Vina provides an interface to AutoDock Vina, which is a widely used program for docking small molecules
(ligands) into biological molecules (receptors). This class provides methods for writing configuration files and for 
processing output. The input/output associated with running Vina is pretty simple, but there is still a fair amount of
scripting required to apply the program to virtual drug-screens that often involve sets of around 100,000 ligands, several
sites (centers) within a given receptor, which may also have multiple configurations.  The goal of this interface is to reduce 
the amount of scripting needed to set up massive drug screens, provide flexibility in analysis/application, and improve
control of what is written into files that can quickly accumulate. For example, the synopsis docks a ligand into a 
receptor for a collection of centers located at the hydroxy group of tyrosine residues; there are a multitude of binding
site prediction software that can be used to provide a collection of centers. Loops over ligands, receptors, centers are 
straightforward to implement, but large screens on a computer cluster will require splitting the loops into chunks that
can be spread across the queueing system.  See the examples.

This class does not include the AutoDock Vina program, which is 
L<released under a very permissive Apache license|http://vina.scripps.edu/manual.html#license>, with few 
restrictions on commercial or non-commercial use, or on the derivative works, such is this. Follow these 
L<instructions | http://vina.scripps.edu/manual.html#installation> to acquire the program. Most importantly, if 
you use this interface effectively, please be sure to cite AutoDock Vina in your work:

O. Trott, A. J. Olson, AutoDock Vina: improving the speed and accuracy of docking with a new scoring function, efficient optimization and multithreading, Journal of Computational Chemistry 31 (2010) 455-461 



( run in 0.960 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )