comparison kmersvm/kmer2meme.pl @ 7:fd740d515502 draft default tip

Uploaded revised kmer-SVM to include modules from kmer-visual.
author cafletezbrant
date Sun, 16 Jun 2013 18:06:14 -0400
parents
children
comparison
equal deleted inserted replaced
6:1aea7c1a9ab1 7:fd740d515502
1 use strict;
2
3 open(my $w_fh, "<", $ARGV[0]);
4 my $num_kmers = $ARGV[1];
5 my @weights = <$w_fh>;
6
7 my @temp_k = @weights[8..(7+$num_kmers), (-$num_kmers..-1)];
8
9 my @kmers = ();
10 #cleanup kmers
11 for my $i (0..($#temp_k)){
12 my @temp = split('\t',$temp_k[$i]);
13 #modified by dongwon 042713
14 #push(@kmers, ($temp[0], $temp[1]));
15 push(@kmers, $temp[0]);
16 }
17
18 open(my $o_fh, ">", "kmer2meme.meme");
19
20 print $o_fh
21 "MEME version 4
22
23 ALPHABET= ACGT
24
25 strands: + -
26
27 Background letter frequencies (from no specific genome):
28 A 0.25 C 0.25 G 0.25 T 0.25\n\n";
29
30 foreach my $kmer (@kmers) {
31 print $o_fh "MOTIF $kmer\n";
32 my $l = length($kmer);
33 print $o_fh "letter-probability matrix: alength= 4 w= $l nsites= 1 E= 0\n";
34 foreach my $i (0..($l-1)) {
35 my $nc = substr($kmer, $i, 1);
36 if ($nc eq "A") {
37 print $o_fh " 1.00 0.00 0.00 0.00\n";
38 }elsif ($nc eq "C") {
39 print $o_fh " 0.00 1.00 0.00 0.00\n";
40 }elsif ($nc eq "G") {
41 print $o_fh " 0.00 0.00 1.00 0.00\n";
42 }elsif ($nc eq "T") {
43 print $o_fh " 0.00 0.00 0.00 1.00\n";
44 }else {
45 print " 0.25 0.25 0.25 0.25\n";
46 }
47 }
48 print $o_fh "\n";
49 }