#!/usr/local/bin/nawk -f # input: DISCOVER mdf file # output: connectivity # strip parts from atom reference, residue and atom name remain function format_atom_name(name){ if ( name ~ /_/ ) { split(name,s,"_") name = s[2] } if ( name ~ /\// ){ split(name,s,"/") name = s[1] } return(name) } BEGIN{ if ( FILENAME == "-" ) { print "usage: mdf2connect.awk " exit } } /@molecule/,/#atomset/{ if ( NF >= 12 ) { # print name of first atom first = format_atom_name($1) printf "%-10s\t\t",first # current residue split(first,s,":") residue = s[1] # print names of connected atoms for ( i=13 ; i<= NF ; ++i ) { name = format_atom_name($i) if ( name !~ /:/ ) name = residue ":" name printf "%s ",name } printf "\n" } }