This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Create Bed File With 3 Tab Delimited Columns Using Matlab

I have MeDIP-seq read counts that is just an array of numbers for each chromosome. For example chr1.txt is just a text file: 0 1 0 0 0 0 2 4 5 6 7 . ......

The resolution is 100 bp.

My question is how can I convert this text file to 3 tab delimited columns using Matlab:

chr                start       end     read_counts 
chr1               1          100            0
chr1            101          200          20
chr1            201           300          0

Thanks !

Amy-

bed

1 answer

in shell command-line you can try this:

count=0; cat chr1.txt | tr "\t" "\n" |  while read line ; do echo "$((count+1))  $((count+100)) $line" ; count=$((count+100)); done

Log in to answer this question.