Skip to content

Instantly share code, notes, and snippets.

@vidboda
vidboda / bedSize.sh
Last active July 29, 2024 09:56
Size of a bed file in bp
awk '{if (/^chr/){n+=$3-$2}}END{print n}' ROI.bed
@vidboda
vidboda / addchr2vcf.sh
Created April 8, 2019 11:06
add chr to a vcf file
zcat file1.vcf.gz | awk -F"\t" '{if ($0 !~ /^#/) {print "chr"$0} else{print $0}}' | bgzip -c >file1chr.vcf.gz
@vidboda
vidboda / change_file_name.sh
Created April 23, 2018 12:34
one liner to change file names with perl
#adapted from https://github.com/Char-Al/Miscellaneous
for i in *.tsv; do NAME=$( perl -pe 's/^(\w+)\.tsv$/$1_coverage.tsv/g' <<< $i);mv $i $NAME;done;
@vidboda
vidboda / intervals2bed.awk
Last active May 9, 2018 14:21
awk to convert position file to BED file
BEGIN { FS="[:-]";OFS="\t"} {print $1,$2-1,$3}
#one-liner:
#awk 'BEGIN { FS="[:-]";OFS="\t"} {print $1,$2-1,$3}' file.list > file.bed
@vidboda
vidboda / bed2intervals.awk
Last active April 6, 2018 15:01
awk to convert bed file to position intervals file
BEGIN {OFS=""} {if ($1 !~ /track/) {print $1,":",$2+1,"-",$3}}
#one-liner:
#awk 'BEGIN {OFS=""} {if ($1 !~ /track/) {print $1,":",$2+1,"-",$3}}' file.bed > file.list