annotate PedToFasta/Ped2Fasta.pl @ 10:c6640c49fd01 draft

planemo upload commit 475f4d7d8442a0d75e103af326ae5881c4d2a4ac
author dereeper
date Mon, 16 Apr 2018 09:00:24 -0400
parents 420b57c3c185
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
1
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
2 #!/usr/bin/perl
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
3
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
4 use strict;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
5 use Getopt::Long;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
6
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
7 my $usage = qq~Usage:$0 <args> [<opts>]
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
8
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
9 where <args> are:
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
10
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
11 -i, --in <PED input>
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
12 -o, --out <Fasta output>
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
13 ~;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
14 $usage .= "\n";
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
15
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
16 my ($input,$out);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
17
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
18
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
19
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
20 GetOptions(
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
21 "in=s" => \$input,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
22 "out=s" => \$out,
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
23 );
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
24
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
25
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
26 die $usage
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
27 if ( !$input || !$out);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
28
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
29
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
30 my %IUPAC =
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
31 (
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
32 '00'=> "?",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
33 'AA'=> "A",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
34 'CC'=> "C",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
35 'GG'=> "G",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
36 'TT'=> "T",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
37 'AG'=> "R",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
38 'GA'=> "R",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
39 'CT'=> "Y",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
40 'TC'=> "Y",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
41 'TG'=> "K",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
42 'GT'=> "K",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
43 'CG'=> "S",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
44 'GC'=> "S",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
45 'AT'=> "W",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
46 'TA'=> "W",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
47 'AC'=> "M",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
48 'CA'=> "M",
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
49 );
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
50
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
51 open(my $O,">$out");
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
52 open(my $P,$input) or die "File does not exist";
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
53 while(<$P>)
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
54 {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
55 my $line = $_;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
56 $line =~s/\r//g;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
57 $line =~s/\n//g;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
58 my @infos = split("\t",$_);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
59 my $ind = $infos[0];
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
60 print $O ">$ind\n";
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
61 for (my $i = 6; $i <= $#infos; $i= $i+2)
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
62 {
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
63 my $code = $infos[$i].$infos[$i+1];
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
64 my $letter = $IUPAC{$code};
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
65 print $O $letter;
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
66 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
67 print $O "\n";
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
68 }
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
69 close($P);
420b57c3c185 Uploaded
dereeper
parents:
diff changeset
70 close($O);