Mercurial > repos > devteam > divide_pg_snp
comparison dividePgSnpAlleles.pl @ 0:de839553d2a2
Uploaded tool tarball.
author | devteam |
---|---|
date | Wed, 25 Sep 2013 10:26:17 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:de839553d2a2 |
---|---|
1 #!/usr/bin/perl -w | |
2 use strict; | |
3 | |
4 #divide the alleles and their information into separate columns for pgSnp-like | |
5 #files. Keep any additional columns beyond the pgSnp ones. | |
6 #reads from stdin, writes to stdout | |
7 my $ref; | |
8 my $in; | |
9 if (@ARGV && $ARGV[0] =~ /-ref=(\d+)/) { | |
10 $ref = $1 -1; | |
11 if ($ref == -1) { undef $ref; } | |
12 shift @ARGV; | |
13 } | |
14 if (@ARGV) { | |
15 $in = shift @ARGV; | |
16 } | |
17 | |
18 open(FH, $in) or die "Couldn't open $in, $!\n"; | |
19 while (<FH>) { | |
20 chomp; | |
21 my @f = split(/\t/); | |
22 my @a = split(/\//, $f[3]); | |
23 my @fr = split(/,/, $f[5]); | |
24 my @sc = split(/,/, $f[6]); | |
25 if ($f[4] == 1) { #homozygous add N, 0, 0 | |
26 if ($ref) { push(@a, $f[$ref]); } | |
27 else { push(@a, "N"); } | |
28 push(@fr, 0); | |
29 push(@sc, 0); | |
30 } | |
31 if ($f[4] > 2) { next; } #skip those with more than 2 alleles | |
32 print "$f[0]\t$f[1]\t$f[2]\t$a[0]\t$fr[0]\t$sc[0]\t$a[1]\t$fr[1]\t$sc[1]"; | |
33 if (scalar @f > 7) { | |
34 splice(@f, 0, 7); #remove first 7 | |
35 print "\t", join("\t", @f), "\n"; | |
36 }else { print "\n"; } | |
37 } | |
38 close FH; | |
39 | |
40 exit; | |
41 |