annotate split.sh @ 7:cbef6b505a8d draft

Uploaded
author zzhou
date Fri, 23 Nov 2012 12:14:59 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
1 #!bin/bash
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
2
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
3 #purpose: shell script which performs the split option
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
4 #author: Ziru Zhou
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
5 #date: October, 2012
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
6
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
7 main()
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
8 {
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
9 output1="${1}"
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
10 output2="${2}"
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
11 input="${3}"
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
12
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
13 $(samtools view -H ${input} > tmp)
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
14 linecount=$(samtools view ${input} | wc -l)
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
15 half=$(((${linecount} + 1) / 2))
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
16 samtools view ${input} | shuf | split -d -l ${half}
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
17
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
18 $(cat tmp x00 > x00h)
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
19 $(cat tmp x01 > x01h)
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
20 samtools view -bSo ${output1} x00h
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
21 samtools view -bSo ${output2} x01h
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
22
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
23 rm tmp x00h x01h x00 x01
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
24 }
cbef6b505a8d Uploaded
zzhou
parents:
diff changeset
25 main "${@}"