#!/bin/perl5 if($#ARGV != 5) { $prgName = $0; $prgName = `basename $prgName`; chomp($prgName); die <Files 4) Unselect Peaks 5) Put in a project name. Just make something up. 6) Select the molecule for NMR_Molecule_Name. 7) Select the .rstrnt file for Restraint_File. 8) Execute. 9) Display restraints using Distance, Dihedral, etc. Usage: $prgName -r [minimum distance] -m dd.mtx -s sequence [> out.rstrnt] EODIE } require "ctime.pl"; require "getopt.pl"; &Getopt('rms'); $minDis = $opt_r; $matrix = $opt_m; $sequence = $opt_s; # Parse the sequence file. Store residue numbers and names in arrays. open(SEQFILE, $sequence) || die("Can't open $sequence: $!\n"); while() { chomp; ($resNum, $resName) = split; push @resNum, $resNum; push @resName, $resName; } close(SEQFILE); #Need this to start the .rstrnt file. print "!BIOSYM restraint 1\n"; #Some comments. print "!Converted from the $matrix discom matrix.\n"; $date = &ctime(time); print "!$date"; print "#distance\n"; # First run through the ddm matrix to grab the atom names. open(DDMFILE, $matrix) || die("Can't open $matrix: $!\n"); while() { @words = split; push @atomNames, $words[2]; } close(DDMFILE); # Second run through the ddm matrix to generate the restraints. # $countLine keeps track of what matrix line we are on. $countLine = 0; open(DDMFILE, $matrix) || die("Can't open $matrix: $!\n"); while() { # Melanie tells me that sometimes negative numbers bump, so add a space. s/-/ -/g; # Grab the numbers from a matrix line. @nums = split; # Build the first atom. $atom1 = "1:$resName[$countLine]_$resNum[$countLine]"; $atom1 .= ":$atomNames[$countLine]"; # Get rid of the junk residue number, residue name and atom name. Just the # numbers, please. shift(@nums); shift(@nums); shift(@nums); # $countNum keeps track of the number for residue numbering. $countNum = 0; # Run through the numbers. foreach $num (@nums) { # Build the second atom. $atom2 = "1:$resName[$countNum]_$resNum[$countNum]"; $atom2 .= ":$atomNames[$countNum]"; # Print the rstrnt, unless it is to itself or has already been printed, # even in reverse. printf("%-15s %-15s %8.3f %8.3f 1.00 1.00 1000.000\n", $atom1, $atom2, $nums[$countNum], $nums[$countNum]) unless($atom1 eq $atom2 || $printed{"$atom1 $atom2"} || $printed{"$atom2 $atom1"} || abs($nums[$countNum]) < $minDis); ++$printed{"$atom1 $atom2"}; ++$printed{"$atom2 $atom1"}; ++$countNum; } ++$countLine; } close(DDMFILE);