annotate vcf2gvf.sh @ 0:21053f7f9ed1 draft

First upload of PCR Marker tools
author john-mccallum
date Thu, 14 Jun 2012 19:29:26 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
1 #!/bin/sh
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
2 ##convert vcf to gvf
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
3 ##NOTE This is a very simple basic parser for a complex format.
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
4
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
5 ##usage vcf2gvf.sh <vcf file> <outputfile>
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
6
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
7 #Copyright 2012 John McCallum & Leshi Chen
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
8 #New Zealand Institute for Plant and Food Research
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
9
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
10 #New Zealand Institute for Plant and Food Research
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
11 #This program is free software: you can redistribute it and/or modify
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
12 # it under the terms of the GNU General Public License as published by
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
13 # the Free Software Foundation, either version 3 of the License, or
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
14 # (at your option) any later version.
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
15 #
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
16 # This program is distributed in the hope that it will be useful,
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
19 # GNU General Public License for more details.
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
20 #
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
21 # You should have received a copy of the GNU General Public License
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
23
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
24
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
25
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
26 inputfile=$1
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
27 outputfile=$2
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
28
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
29 echo "##gvf-version 1.05" > $outputfile
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
30
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
31 awk '
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
32 BEGIN {OFS="\t"}
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
33
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
34 ##get feature type
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
35 {if (index($8,"INDEL")== 1) {type="INDEL"} else {type="SNP"} }
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
36 ##get feature length
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
37 {if (type=="SNP")
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
38 {feat_length=1}
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
39 else {feat_length=length($4)}
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
40 }
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
41 {end=($2+feat_length)}
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
42
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
43 !/^#/ { print $1 ,"SAMTOOLS",type,$2,end,$6,".",".","ID="$1":SAMTOOLS:"type":"$2";Variant_seq="$5";Reference_seq="$4";"$8}
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
44
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
45 END {print ""}
21053f7f9ed1 First upload of PCR Marker tools
john-mccallum
parents:
diff changeset
46 ' "$inputfile" > "$outputfile"