Difference between revisions of "Grep log file"

From relax wiki
Jump to navigation Jump to search
(Added an intro sentence.)
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
The following describes how to convert a relax log file into a relax script.
 +
 
== Grep the log file for commands ==
 
== Grep the log file for commands ==
 
First we find which commands relax has performed, and separate into the different fitting models.<br>
 
First we find which commands relax has performed, and separate into the different fitting models.<br>
We also just make some line space and important points
+
We also just make some line space and important points.
egrep -wi --color 'relax>| model -' LOGFILE.txt > greplogfile.txt
+
 
Then we replace instances of '''relax> ''' with empty, and comment out the model line
+
Then we replace instances of '''relax> ''' with empty, and comment out the model line.
sed -i "s/relax> //" greplogfile.txt ;
+
 
sed -i 's/^- /\n#- /' greplogfile.txt ;
+
Put this into a file: '''relax_log_to_py.sh'''
sed -i 's/^minimise(/\nminimise(/' greplogfile.txt ;
+
<source lang="bash">
sed -i '0,/spectrum.replicated(/s//\nspectrum.replicated(/' greplogfile.txt;
+
#!/bin/tcsh -f
 +
 
 +
set LOGS=`ls -v -d -1 *.log`
 +
foreach LOG ( ${LOGS} )
 +
set BNAME=`basename $LOG .log`
 +
set OUT="grep_${BNAME}.py"
 +
egrep -wi --color 'relax>| model -' $LOG > $OUT ;
 +
sed -i "s/relax> //" $OUT ;
 +
sed -i 's/^- /\n#- /' $OUT ;
 +
sed -i 's/^minimise(/\nminimise(/' $OUT ;
 +
sed -i 's/^script(/\n#script(/' $OUT ;
 +
sed -i 's/^results.write(/\nresults.write(/' $OUT ;
 +
sed -i 's/^model_selection(/\nmodel_selection(/' $OUT ;
 +
sed -i '0,/spectrum.replicated(/s//\nspectrum.replicated(/' $OUT ;
 +
sed -i '0,/spectrum.read_intensities(/s//\nspectrum.read_intensities(/' $OUT ;
 +
end
 +
</source>
 +
 
 +
Make it executable
 +
<source lang="bash">
 +
chmod +x relax_log_to_py.sh
 +
</source>
 +
 
 +
End then execute it
 +
<source lang="bash">
 +
./relax_log_to_py.sh
 +
# OR
 +
tcsh relax_log_to_py.sh
 +
</source>
 +
 
 +
Then look out for files starting with '''grep_'''.
  
 
== See also ==
 
== See also ==
Line 13: Line 45:
  
 
[[Category:grep]]
 
[[Category:grep]]
 +
[[Category:Results]]

Latest revision as of 17:47, 22 October 2015

The following describes how to convert a relax log file into a relax script.

Grep the log file for commands

First we find which commands relax has performed, and separate into the different fitting models.
We also just make some line space and important points.

Then we replace instances of relax> with empty, and comment out the model line.

Put this into a file: relax_log_to_py.sh

#!/bin/tcsh -f

set LOGS=`ls -v -d -1 *.log`
foreach LOG ( ${LOGS} )
set BNAME=`basename $LOG .log`
set OUT="grep_${BNAME}.py"
egrep -wi --color 'relax>| model -' $LOG > $OUT ;
sed -i "s/relax> //" $OUT ;
sed -i 's/^- /\n#- /' $OUT ;
sed -i 's/^minimise(/\nminimise(/' $OUT ;
sed -i 's/^script(/\n#script(/' $OUT ;
sed -i 's/^results.write(/\nresults.write(/' $OUT ;
sed -i 's/^model_selection(/\nmodel_selection(/' $OUT ;
sed -i '0,/spectrum.replicated(/s//\nspectrum.replicated(/' $OUT ;
sed -i '0,/spectrum.read_intensities(/s//\nspectrum.read_intensities(/' $OUT ;
end

Make it executable

chmod +x relax_log_to_py.sh

End then execute it

./relax_log_to_py.sh
# OR
tcsh relax_log_to_py.sh

Then look out for files starting with grep_.

See also

Sed one-liners