[Bio] / Sprout / LoaderUtils.pm Repository:
ViewVC logotype

Annotation of /Sprout/LoaderUtils.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     package LoaderUtils;
4 :    
5 :     use strict;
6 :     use Tracer;
7 :    
8 :     =head1 Common DB Load Utilities
9 :    
10 :     =head2 Introduction
11 :    
12 :     This package contains static methods used by both the Sprout and Sapling loaders.
13 :    
14 :     =head2 Public Methods
15 :    
16 :     =head3 ReadAliasFile
17 :    
18 :     my $aliasHash = LoaderUtils::ReadAliasFile($dir, $genomeID);
19 :    
20 :     This method reads the content of the alias file for the specified genome,
21 :     and returns a hash. For each feature, the hash contains a list of its
22 :     aliases. Each alias is represented by a 3-tuple consisting of the actual
23 :     alias, the alias type (e.g. C<CMR>, C<NCBI>), and the confidence code--
24 :     C<A> for a curated alias, C<B> for a non-curated feature alias, and C<C>
25 :     for a protein alias. If the alias file is not found, an error will occur.
26 :    
27 :     =over 4
28 :    
29 :     =item dir
30 :    
31 :     Name of the directory containing the alias files.
32 :    
33 :     =item genomeID
34 :    
35 :     ID of the genome whose alias file is to be read.
36 :    
37 :     =item RETURN
38 :    
39 :     Returns a reference to a hash of feature IDs to alias lists. For each feature,
40 :     the alias list will be a reference to a list of 3-tuples. Each 3-tuple will
41 :     contain an alias ID, an alias type, and a confidence level from C<A> (highest)
42 :     to C<C> (lowest). If the alias file is not found, it will return an undefined
43 :     value.
44 :    
45 :     =back
46 :    
47 :     =cut
48 :    
49 :     sub ReadAliasFile {
50 :     # Get the parameters.
51 :     my ($dir, $genomeID) = @_;
52 :     # Declare the return variable.
53 :     my $retVal = {};
54 :     # Find the alias file. The alias files are created by "AliasCrunch.pl".
55 :     my $aliasFile = "$dir/alias.$genomeID.tbl";
56 :     if (! -f $aliasFile) {
57 :     undef $retVal;
58 :     } else {
59 :     # The file exists, so open it for input.
60 :     my $aliasH = Open(undef, "<$aliasFile");
61 :     # Loop through the file.
62 :     while (! eof $aliasH) {
63 :     # Get this alias record.
64 :     my ($aliasFid, $aliasID, $aliasType, $aliasConf) = Tracer::GetLine($aliasH);
65 :     # Put it in the return hash.
66 :     push @{$retVal->{$aliasFid}}, [$aliasID, $aliasType, $aliasConf];
67 :     }
68 :     # Close the file: we're done with it.
69 :     close $aliasH;
70 :     # Do a memory trace. Alias files can be pretty big.
71 :     MemTrace("Aliases adjusted.") if T(ERDBLoadGroup => 3);
72 :     }
73 :     # Return the result.
74 :     return $retVal;
75 :     }
76 :    
77 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3