Blogs
Links
|
[Sun, 13 Jun 2004]
I always liked Python more than Perl. The conversion is now complete. The only Perl code I now write are one-liners. Python can't be used to write one-liners but its verbosity and forced indentation and intuitive function names make it easy to read. And the final time to write the program isn't that much anyway. Now that I've gotten used to its modules, its gotten easier for me to write scripts that do lots of pipes and program-running business. These days, during the course of work, a hairy command line will typically pull in many different languages: cat test3_${j}_${i%.policy}.ct | perl -ne '{chomp; print "echo ",$_," | addZero | chainbuild --param '${j}.prm' --fixomega --pdb > test3_decoy_'${j}_${i%.policy}'_",$.,".gly \n ./nbEasy test3_decoy_'${j}_${i%.policy}'_",$.,".gly | grep neighbouring \n"; }' > test3_${j}_${i%.policy}.1 ls ${j}/test3_runs/$i| GetStructParamsAll.py | tail -1 | perl -pe 's/\s+/\n/g;' | sed '1 d'| perl -ne '{chomp; if ($.%3==2) {print;} if ($.%3==0) {print " ", $_, "\n";}}'| perl -ne '{ if (/\S+\s+\S+/) {print;}}' > ${j}/test4_runs/${i%.gly}.tors chainbuild is a C++ program, with 3rd-party Fortran libraries. I use awk/sed usually, and call in Perl's regexes if awk would get too unwieldy. Perl's -pe/-ne flags are really handy. Shell scripting is useful for running simulations and any script that is permanent enough to go into a file is almost always Python. Sometimes I wonder if I go overboard with this scripting business. But, then again, its pretty useful. |