#!/usr/bin/perl # the above is the standard linux/unix path for perl: change if your computer is nonstandard sub print_help{ print STDERR <0 or die "Invalid index $index\n"; next; } if($p eq "-s"){ $symbol=shift(@ARGV); next; } if($p eq "-h"){ # help print_help; die "\n"; } print_help; die "invalid option $p\n"; } if($#inputfiles<0){ push(@inputfiles,"-"); # adds stdio for lack of arguments } $count=-1; $actualframes=0; while ($filename=shift(@inputfiles)){ $natom=0; $count=0; $totp=0; $frames=0; open(INPUT, $filename) || die "Cannot open $filename\n"; while(){ s/^\s*//; # remove leading spaces @li = split('\s+'); if($#li==0 && $count!=1){ $count=0; $frames++; @ato=(); @atpo=(); $natom=$li[0]+0; $index<=$natom or die "delete index $index > $natom\n"; print $natom-1,"\n"; } if($count==1){ $comment=$_; $comment=~s/\n//;; print "$comment - deleted atom $index\n"; } if($count>1){ if($count-1!=$index){ print; }else{ shift @li; print $symbol,"\t@li","\n"; } } $count++; } close(INPUT); } while(){ s/^\s*//; @li = split('\s+'); if($#li==0 && $li[0]+0==$li[0]){ $count++; $natms = $li[0]; $index <= $natms or die "index $index is not compatible with this xyz file, with $natms atoms only\n"; $_=; s/^\s*//; @li = split('\s+'); $time=$li[1]+0.; if($time<=0){ $time=$count; } for($i=1;$i<=$natms;$i++){ $_=; if($i == $index){ s/^\s*//; @li = split('\s+'); print $time,"\t",$li[1],"\t",$li[2],"\t",$li[3],"\n", } } } } close(INPUT);