#!/usr/bin/perl
#
# Perl script to write one file of PDB coordinates
# starting from a set of files coming from CNS calcs
#
while ( <> ) {
  next if ( / ANI   500 / );     # avoid ANI residue
  if ($_ =~ /.*FILENAME*/) {
        @Name=split('.pdb',$_);
	@Campo=split('_',$Name[0]);
	$model++ ;
  	#print "MODEL          $Campo[2]\n";
  	print "MODEL          $model\n";
  } elsif ($_ =~ /.*overall*/ ) {
        print "$_" ;
  } elsif ($_ =~ /^REMARK/ ) {
        print "$_";
  } elsif ($_ =~ /END/ ) {
        print "ENDMDL\n" ;
  } else {
  	print "$_";
  }
}
