#!/usr/local/bin/perl -w # break-ts-into-pdb robetta.pdb # parses a CASP TS format submission into separate models # generating robetta1.pdb, robetta2.pdb, ... # The sole argument must be a file name ending with .pdb # containing PDB ATOM records with MODEL/END separators ($filename) = @ARGV; $filename =~ /(\S+)[.]pdb$/; $fileroot = $1; open(TS, "<$filename") || die "Error: can't read $filename\n"; undef $modelnum; while() { if (defined($modelnum) && /^ATOM/) { print OUT $_; } elsif (/^MODEL\s+(\d+)/) { $modelnum = $1; $outname = $fileroot. $modelnum. ".pdb"; open (OUT , ">$outname") || die "Can't write to $outname\n"; } elsif (/^END/) { undef $modelnum; close OUT; } }