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

Apr 8, 2020

bedops --chop : chop bed into identical intervals


https://bedops.readthedocs.io/en/latest/content/reference/set-operations/bedops.html

The --chop operator merges all overlapping input regions and “chops” them up into a set of disjoint segments of identical length (with a default of one base). One or more input files may be provided; this option will segment regions from all inputs:

Note
Overlapping and nested regions are merged into contiguous ranges before chopping. The end result contains unique, non-overlapping elements.

(base) [lee@ko44 annotation]$ more chrom.sizes.chr.TAIR10.bed
chr1    0    30427671
chr2    0    19698289 
chr3    0    23459830
chr4    0    18585056
chr5    0    26975502


 (base) [lee@ko44 annotation]$ bedops --chop 1000 chrom.sizes.chr.TAIR10.bed > arabidopsis_1kb_chr1_5.bed

(base) [lee@ko44 annotation]$ more arabidopsis_1kb_chr1_5.bed
chr1    0    1000
chr1    1000    2000
chr1    2000    3000
chr1    3000    4000
chr1    4000    5000
chr1    5000    6000
chr1    6000    7000
chr1    7000    8000