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

Annotation of /FigKernelScripts/assign_synonym_ids.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1 #
2 : olson 1.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 :     #
19 : olson 1.1 # Walk the peg.synonyms file assigning each entry a unique synonym id.
20 :     #
21 :     # The current principal synonym is moved to the front of the list of other synonyms.
22 :     #
23 :    
24 :     use strict;
25 :    
26 :     my $usage = "assign_synonym_ids peg.synonyms new.peg.synonyms id_map";
27 :    
28 :     if (@ARGV != 3)
29 :     {
30 :     die $usage;
31 :     }
32 :    
33 :     my $input = shift;
34 :     my $output = shift;
35 :     my $map = shift;
36 :    
37 :     open(FH, "<$input") or die "Cannot open $input: $!\n";
38 :     open(OUT, ">$output") or die "Cannot open $output for writing: $!\n";
39 :     open(MAP, ">$map") or die "Cannot open $map for writing: $!\n";
40 :    
41 :     my $next_id = 1;
42 :    
43 :     while (<FH>)
44 :     {
45 :     my $syn_id = sprintf("xxx%08d", $next_id++);
46 :    
47 :     print "$.\n" if $. % 100000 == 0;
48 :    
49 :     chomp;
50 :     my($f1, $list) = split(/\t/);
51 :    
52 :     my($pri_syn, $pri_len) = split(/,/, $f1);
53 :    
54 :     print OUT "$syn_id,$pri_len\t$f1;$list\n";
55 :     print MAP "$pri_syn\t$syn_id\n";
56 :     }
57 :    
58 :     close(OUT);
59 :     close(MAP);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3