#!/bin/sh # # Author: Gregory L. Warren 04/08/98 # # copyright Yale University # # Sort out non-NOE restraints for a loop region. # The sorting is required for loop multi-conformer refinement. # Data must exist in a specific format for this awk script to work # use the single conformer tables for ensemble.inp # # This script assumes segid's exist in the assignment table # # THERE MUST BE A BLANK LINE SEPARATING ASSIGN STATEMENTS # assign ( resid 28 and name hb2) ( resid 18 and name hb1) 4.2 2.4 0.8 # # assign ( resid 28 and name hb2) ( resid 18 and name hb1) 4.2 2.4 0.8 # # NOT # assign ( resid 28 and name hb2) ( resid 18 and name hb1) 4.2 2.4 0.8 # assign ( resid 28 and name hb2) ( resid 18 and name hb1) 4.2 2.4 0.8 # # assignment statements can be on multiple lines # ASSIgn ((segid C1 and resid 22 and name HA )) # ((segid C1 and resid 22 and name HG21) # OR (segid C1 and resid 22 and name HG22) # OR (segid C1 and resid 22 and name HG23)) # 3.3679 0.7746 0.7746 { previous: 3.4232 0.7873 0.7873 } if [ $# -eq 0 ] then echo "Enter the restraint file name: " read fname fi awk ' BEGIN { cnt = 0; test = 0; test2 = 0; test3 = 0; resj = 10000; resk = 10000; segj = 10000; segk = 10000; suff = ".tbl"; printf "Enter the number of conformers: " getline nconf <"-" printf "Enter non-loop output prefix: " getline onlp <"-" printf "Enter loop output prefix: " getline olp <"-" printf "Enter the loop low residue number: " getline lownum <"-" lownum = lownum - 1; printf "Enter the loop high residue number: " getline highnum <"-" highnum = highnum + 1; for (i=1; i <= nconf; i++ ) { nloop[i] = onlp sprintf("%s",i) suff; loop[i] = olp sprintf("%s",i) suff; } } { for (i=1; i <= NF; i++ ) { if ( $i ~ /[rR][eE][sS][iI]+/ ) { if ( test2 == 0) { resj = i + 1; test2++; } else { resk = i + 1; } } if ( $i ~ /[sS][eE][gG][iI]+/ ) { if ( test3 == 0) { segj = i + 1; test3++; } else { segk = i + 1; } } } if ( resj != 10000 ) { if ( $resj > lownum && $resj < highnum ) { cnt++; test++; test2=0; test3=0; if ( resk == 10000) { for (i=1; i <= nconf; i++ ) { if ( segj != 10000 ) $segj = "C" sprintf("%s",i); store[i,cnt] = $0; } resj = 10000; resk = 10000; segj = 10000; } else { if ( $resk > lownum && $resk < highnum ) { for (i=1; i <= nconf; i++ ) { if ( segj != 10000 ) $segj = "C" sprintf("%s",i); if ( segk != 10000 ) $segk = "C" sprintf("%s",i); store[i,cnt] = $0; } } else { for (i=1; i <= nconf; i++ ) { if ( segj != 10000 ) $segj = "C" sprintf("%s",i); if ( segk != 10000 ) $segk = "C0"; store[i,cnt] = $0; } } resj = 10000; resk = 10000; segj = 10000; segk = 10000; } } else if ( resk != 10000) { if ( $resk > lownum && $resk < highnum ) { cnt++; test++; test2=0; test3=0; for (i=1; i <= nconf; i++ ) { if ( segj != 10000 ) $segj = "C0"; if ( segk != 10000 ) $segk = "C" sprintf("%s",i); store[i,cnt] = $0; } resj = 10000; resk = 10000; segj = 10000; segk = 10000; } else { cnt++; test2=0; test3=0; for (i=1; i <= nconf; i++ ) { if ( segj != 10000 ) $segj = "C0"; if ( segk != 10000 ) $segk = "C0"; store[i,cnt] = $0; } resj = 10000; resk = 10000; segj = 10000; segk = 10000; } } else { cnt++; test2=0; test3=0; for (i=1; i <= nconf; i++ ) { if ( segj != 10000 ) $segj = "C0"; store[i,cnt] = $0; } resj = 10000; resk = 10000; segj = 10000; } } else { cnt++; test3=0; for (i=1; i <= nconf; i++ ) { store[i,cnt] = $0; } } if ( $1 ~ /^$/ ) { if ( test > 0 ) { for (i = 1; i <= nconf; i++ ) { for (k = 1; k <= i; k++ ) { for (j = 1; j <= cnt; j++ ) { print store[k,j] >>loop[i]; } } } cnt = 0; test = 0; } else { for (i = 1; i <= nconf; i++ ) { for (j = 1; j <= cnt; j++ ) { print store[i,j] >>nloop[i]; } } cnt = 0; test = 0; } } } ' $fname