annotate dividePgSnpAlleles.pl @ 1:f74fdfc17143 default tip

Removed excess version attributes.
author Dave Bouvier <dave@bx.psu.edu>
date Tue, 03 Dec 2013 12:36:12 -0500
parents de839553d2a2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
1 #!/usr/bin/perl -w
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
2 use strict;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
3
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
4 #divide the alleles and their information into separate columns for pgSnp-like
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
5 #files. Keep any additional columns beyond the pgSnp ones.
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
6 #reads from stdin, writes to stdout
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
7 my $ref;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
8 my $in;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
9 if (@ARGV && $ARGV[0] =~ /-ref=(\d+)/) {
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
10 $ref = $1 -1;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
11 if ($ref == -1) { undef $ref; }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
12 shift @ARGV;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
13 }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
14 if (@ARGV) {
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
15 $in = shift @ARGV;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
16 }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
17
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
18 open(FH, $in) or die "Couldn't open $in, $!\n";
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
19 while (<FH>) {
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
20 chomp;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
21 my @f = split(/\t/);
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
22 my @a = split(/\//, $f[3]);
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
23 my @fr = split(/,/, $f[5]);
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
24 my @sc = split(/,/, $f[6]);
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
25 if ($f[4] == 1) { #homozygous add N, 0, 0
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
26 if ($ref) { push(@a, $f[$ref]); }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
27 else { push(@a, "N"); }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
28 push(@fr, 0);
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
29 push(@sc, 0);
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
30 }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
31 if ($f[4] > 2) { next; } #skip those with more than 2 alleles
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
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]";
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
33 if (scalar @f > 7) {
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
34 splice(@f, 0, 7); #remove first 7
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
35 print "\t", join("\t", @f), "\n";
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
36 }else { print "\n"; }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
37 }
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
38 close FH;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
39
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
40 exit;
de839553d2a2 Uploaded tool tarball.
devteam
parents:
diff changeset
41