Figure from Medium
I would like to print genes in each sliding window into a new file, so that I can make test on each one.
For a simple example,
|
|
I would like to print sliding 5 elements: window size = 5 and sliding size =2, eg.
1 2 3 4 5
3 4 5 6 7
5 6 7 8 9
For the above 22 elements, I will need to print 1-5, 3-7, 5-9, 7-11, 9-13, 11-15, 13-17, 15-19, 17-21 in total 9 sliding windows, which equals (22-5)%2 + 1. We need to go through a for loop to print elements in each sliding window:
The first line is i, then the last line is i+4
Below is a bash script to do this, where I need to define variables for window size, sliding size, etc
|
|
If we do
./test.sh testfile
Then gives:
|
|