Thursday, January 12, 2012

Useful perl code

#!/usr/bin/perl

$infile  = "./test.pdb";
$outa = "./test.pdb.A";
$outb = "./test.pdb.B";
open (FH,$infile) || die;
open (OUTA, ">$outa") || die;
open (OUTB, ">$outb") || die;

while ($buf = )
{
    $x = substr($buf,16,1);
    if ($x eq 'A') { print OUTA $buf; }
    elsif ($x eq 'B') { print OUTB $buf; }
    else { print OUTA $buf; print OUTB $buf; }
}

close FH;
close OUTA;
close OUTB;


# This code reads in a file and if the 17th column in each line matches A/B, that line is put in OUTA/OUTB.This is useful in separating multiple coordinates for particular residues in 3D coordinate file of a protein. Sometimes studying all possible conformations is important especially if it involves an aromatic ring flip or flips in residues with amine ends.

No comments:

Post a Comment