page

Jun 9, 2020

bedtools map : map overlapping features and calculate sum, count, min, max, mean, median



bedtools map allows one to map overlapping features in a B file onto features in an A file and apply statistics and/or summary operations on those features.


../../_images/map-glyph.png

Jun 8, 2020

parallel-fastq-dump


parallel fastq-dump wrapper

https://cloud.githubusercontent.com/assets/6310472/23962085/bdefef44-098b-11e7-825f-1da53d6568d6.png

print range of columns


input:
column1,column2,column3,column4,column5,column6,column7,column8

output:

column2,column3,column4,column5,column6,column7

Answer

cut -d, -f2-7 <input-file>

or

$ awk -v b=2 -v e=7 'BEGIN{FS=OFS=","} {for (i=b;i<=e;i++) printf "%s%s", $i, (i<e ? OFS : ORS)}' file

b=beginning field number, e=end field number.

Adding a Column of values in a tab delimited file


Input file:

SPATA17 1   217947738
LYPLAL1 1   219383905
FAM47E  4   77192838
SHROOM3 4   77660162
SHROOM3 4   77660731
SHROOM3 4   77662248

Output file:

SPATA17 1   217947738 file1
LYPLAL1 1   219383905 file1
FAM47E  4   77192838  file1
SHROOM3 4   77660162  file1
SHROOM3 4   77660731  file1
SHROOM3 4   77662248  file1

Answer

for file in *; do awk 'BEGIN{OFS="\t"}{print $0, FILENAME}' $file; done


FILENAME is a variable in awk, it expand to current file name that awk is processing.




How to replace dot in linux

https://stackoverflow.com/questions/27205566/how-to-replace-dot-in-linux


# substitute . to NA

awk 'BEGIN {OFS=FS="\t"} {for (i=1;i<=NF;i++) {gsub(/^\.$/,"NA",$i)}}1' file

/^\.$/ to assure that nothing precedes or follows the dot