Difference between revisions of "One-liners"

From wiki
Jump to: navigation, search
(Created page with " You have a genome coverage file in bedgraph format (final, fourth column is the coverage for a particular section) amd would like to find the max value: awk '{if($4>mxc) m...")
 
Line 8: Line 8:
  
 
  awk '{tot=tot+$4/($3-$2); la=$3} END {print tot/la}' v30chronly_s.cov
 
  awk '{tot=tot+$4/($3-$2); la=$3} END {print tot/la}' v30chronly_s.cov
 +
 +
Note how in the above, for '''la''' (last), we want the  third column on the last line which is the endpoint, but we don't know when it will occur so the third column on all lines get assigned to this variable. This will not do if there is more than one chromosome.

Revision as of 18:00, 13 March 2017


You have a genome coverage file in bedgraph format (final, fourth column is the coverage for a particular section) amd would like to find the max value:

awk '{if($4>mxc) mxc=$4} END {print mxc}' v30chronly_s.cov

A genome coverage file what is the average coverage per base?

awk '{tot=tot+$4/($3-$2); la=$3} END {print tot/la}' v30chronly_s.cov

Note how in the above, for la (last), we want the third column on the last line which is the endpoint, but we don't know when it will occur so the third column on all lines get assigned to this variable. This will not do if there is more than one chromosome.