[Bio] / FigKernelScripts / ali_to_seq.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/ali_to_seq.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : olson 1.2 #
2 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 : overbeek 1.1 # usage: ali_to_seq < ali > seqs
19 :    
20 :     $/ = "\n>";
21 :     while (defined($_ = <STDIN>))
22 :     {
23 :     chomp;
24 :     if ($_ =~ /^>?(\S+)[^\n]*\n(.*)/s)
25 :     {
26 :     $id = $1;
27 :     $seq = $2;
28 :     $seq =~ s/\n//gs;
29 :     $seq =~ s/ //gs;
30 :     $seq =~ s/[\-\.\~]//gs;
31 :     $seq = lc $seq;
32 :     $seq =~ s/u/t/g;
33 :     &display_id_and_seq($id,\$seq);
34 :     }
35 :     }
36 :    
37 :     sub display_id_and_seq {
38 :     my( $id, $seq, $fh ) = @_;
39 :    
40 :     if (! defined($fh) ) { $fh = \*STDOUT; }
41 :    
42 :     print $fh ">$id\n";
43 :     &display_seq($seq, $fh);
44 :     }
45 :    
46 :     sub display_seq {
47 :     my ( $seq, $fh ) = @_;
48 :     my ( $i, $n, $ln );
49 :    
50 :     if (! defined($fh) ) { $fh = \*STDOUT; }
51 :    
52 :     $n = length($$seq);
53 :     # confess "zero-length sequence ???" if ( (! defined($n)) || ($n == 0) );
54 :     for ($i=0; ($i < $n); $i += 60)
55 :     {
56 :     if (($i + 60) <= $n)
57 :     {
58 :     $ln = substr($$seq,$i,60);
59 :     }
60 :     else
61 :     {
62 :     $ln = substr($$seq,$i,($n-$i));
63 :     }
64 :     print $fh "$ln\n";
65 :     }
66 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3