5 use Data
::Dump
qw(ddx);
7 die "Usage: $0 <input msf> <output>\n" if @ARGV < 2;
10 open OUT
,'>',$outf or die;
12 my $in = Bio
::AlignIO
->new(-file
=> $inf,
15 my $alnObj = $in->next_aln(); # get entire alignment data
17 my (%Seq,$cns,$combined,@CNS,$t,@ids);
18 foreach my $seqObj ($alnObj->each_seq) {
19 print join(',',$seqObj->display_id), "\n";
20 push @ids,$seqObj->display_id;
21 my $seq = $seqObj->seq;
22 $Seq{$seqObj->display_id}=[-1,0,$seq];
23 my @bases = split //,$seq;
27 if (exists $CNS[$t]) {
32 if ($Seq{$seqObj->display_id}->[0] == -1) {
33 $Seq{$seqObj->display_id}->[0] = $t + 1;
39 $Seq{$seqObj->display_id}->[1] = length($seq);
46 #/share/users/huxs/git/toGit/perl/perlib/etc/Galaxy/Data.pm
47 our %REV_IUB = (A
=> 'A',
65 my %ATGtoBIN = ( A
=> 1,C
=> 2,G
=> 4,T
=> 8 );
70 my %thebase = %{$base};
71 $t = (sort { $thebase{$b} <=> $thebase{$a} } keys %thebase)[0];
74 $t = join '',(sort { $a cmp $b } keys %thebase);
75 $combined .= $REV_IUB{$t} or die;
78 print "$cns\n$combined\n";
80 my $Main = (split /\*/,$ids[0])[0];
82 <?xml version="1.0" encoding="UTF-8"?>
83 <reference schema="350">
84 <name>${Main}_Alleles</name>
85 <library>${Main}</library>
86 <comments>No Comment</comments>
87 <version>2012_Tang</version>
89 <max_deletion>5</max_deletion>
90 <consensus>$cns</consensus>
91 <combined>$combined</combined>
97 my ($start,$stop,$seq) = @
{$Seq{$id}};
98 my @bases = split //,$seq;
102 if ($b ne '.' and $b ne $CNSbases[$t]) {
103 push @variants,join(' ',$t+1,$ATGtoBIN{$b});
104 print "$id:$t $b ne $CNSbases[$t]\n";
108 $t = join(' ',@variants);
113 <start>$start</start>
115 <variants>$t</variants>
120 print OUT
'</allele-list>