#!/bin/perl #Perl script to remove unnecessary intra-residue restraints from a DIANA format list #removes all intraresiudes restraints that are separated by 3 bonds or less #and all proline intraresidiues, and all intra-ring restraints for Phe and Tyr #removes HN, HA, HB to HE or HZ in aromatics #removes i -> i+3 HN->Hns #removes HN i -> HA i+1 #command line: diana_filt inputfile [>outfile]; #Melanie Nelson #5/19/99 #use aromlist to clean up filtering #it is list of aromatic ring protons; restraints within this group on the #same ring are filtered out $aromlist = "-HZ-CG-CZ"; open (FILE, $ARGV[0]) || die "Could not open restraint file $ARGV[0]\n"; while (){ #save the linput line for easy printing later $inline = $_; chomp; #split the line into an array for filtering steps @inline = split; #extra split step so I can just cut and paste in from Randy's ambihnhx-- will fix this later #to make it nicer. @words = split(' '); $rNum1 = $words[0]; $rName1 = $words[1]; $aName1 = $words[2]; $rNum2 = $words[3]; $rName2 = $words[4]; $aName2 = $words[5]; #do the filtering: print by default (flag = 1) #set flag to zero if an excluding condition is met $flag = 1; #all excluding conditions are intraresidue if ($inline[0] == $inline[3]){ #first do the general case intraresidue exclusions (3 bonds or less separating #the two protons) #HGs require long way cuz of the aromatics (CG) if ($inline[2] eq 'HN' && $inline[5] =~ 'A'){ $flag = 0; } elsif ($inline[2] =~ 'A'){ if ($inline[5] eq 'HN' || $inline[5] =~ 'B' || $inline[5] =~ 'A'){ $flag = 0; } } elsif ($inline[2] =~ 'B'){ if ($inline[5] =~ 'A' || $inline[5] =~ 'HG' || $inline[5] =~ 'QG' || $inline[5] =~ 'B'){ $flag = 0; } } elsif ($inline[2] =~ 'HG' || $inline[2] =~ 'QG'){ if ($inline[5] =~ 'B' || $inline[5] =~ 'D' || $inline[5] =~ 'HG' || $inline[5] =~ 'QG'){ $flag = 0; } } elsif ($inline[2] =~ 'D'){ if ($inline[5] =~ 'HG' || $inline[5] =~ 'QG' || $inline[5] =~ 'E' || $inline[5] =~ 'D'){ $flag = 0; } } elsif ($inline[2] =~ 'E'){ if ($inline[5] =~ 'D' || $inline[5] =~ 'E'){ $flag = 0; } } #now intra-ring restraints are filtered out #also filter out special case non-ring intraresidue: Phe/Tyr HB->ring #protons if ($inline[1] eq 'PRO'){ $flag = 0; } elsif ($inline[1] eq 'PHE' || $inline[1] eq 'TYR'){ if (($aromlist =~ "-$inline[2]") && ($aromlist =~ "-$inline[5]")){ $flag = 0; } } #now include stuff from Randy's ambihnhx script: #aromatic betas to HEs (CZ) and HZ $flag = 0 if($rNum1 == $rNum2 && ($aName1 =~ /HN|HA|QPA|HB|MB|QPB/ && $aName2 =~ /CZ|HZ/)); $flag = 0 if($rNum1 == $rNum2 && ($aName2 =~ /HN|HA|QPA|HB|MB|QPB/ && $aName1 =~ /CZ|HZ/)); } #rest is not intra-residue if ($inline[2] eq 'HN' && $inline[5] eq "HN"){ if ($inline[0]+3 == $inline[3] || $inline[3]+3 == $inline[0]){ $flag = 0; } } #now filter out HN i -> HA or HB i+1 if (($inline[0]+1 == $inline[3] && $inline[2] eq 'HN' && ($inline[5] =~ 'A' || $inline[5] =~ 'B') ) || ($inline[3]+1 == $inline[0] && $inline[5] eq 'HN' && ($inline[2] =~ 'A' || $inline[5] =~ 'B'))){ $flag = 0; } if ($flag == 1){ print $inline } }