annotate split.sh @ 3:e623e9c7bb23 draft

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