#!/usr/bin/perl
#get all the atom types of one molecule from CRYOFF.
if( $ARGV[0] eq '-h' || $ARGV[0] eq '-help')
{
help();
exit;
}
sub help {
  print "\nExtract the atom types of one molecule from the off file.\n";
  print "Usage: offget_moltype  file.off  mol_name \n\n";
}


$bnk="    ";
 
$filename=$ARGV[0];shift; 
$molename=$ARGV[0];
open (FIL,$filename) || die "can not open file $filename"."\n";

print $molename."\n";
while(<FIL>)
{
if (/MOLTYP/) {
  if (/$molename/i) {
    $_=<FIL>;
    $_ =~ s/\[|\]//g;
    ($text,$Natm)=split;
    for ($n=0;$n<$Natm;$n++){
      $_=<FIL>;
      chomp;
      ($num,$nam)=split;
      print $num."    ".$nam."\n";
    }
    last;    
  }
  }
}
