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

Annotation of /FigKernelScripts/make_assertions_from_uploads.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1
2 :     use strict;
3 :     use FIG;
4 :     my $fig = new FIG;
5 :    
6 :     my $usage = "usage: make_assertions_from_uploads UploadDirectory > assertions";
7 :    
8 :     my $upload_dir;
9 :     ($upload_dir = shift @ARGV)
10 :     || die $usage;
11 :    
12 :     opendir(UPLOADS,$upload_dir) || die "could not open $upload_dir";
13 : overbeek 1.2 my @users = grep { ($_ !~ /^\./) && (-d "$upload_dir/$_") } readdir(UPLOADS);
14 : overbeek 1.1 closedir(UPLOADS);
15 :    
16 :     my $user;
17 :     foreach $user (@users)
18 :     {
19 :     opendir(USERDIR,"$upload_dir/$user") || die "could not open $upload_dir/$user";
20 : overbeek 1.2 my @files = sort { $a =~ /clean.(\d+)/; my $x = $1;
21 :     $b =~ /clean.(\d+)/; $x <=> $1 }
22 :     grep { $_ =~ /clean/ } readdir(USERDIR);
23 : overbeek 1.1 closedir(USERDIR);
24 : overbeek 1.2
25 :    
26 : overbeek 1.1
27 :     my $file;
28 : overbeek 1.2 my %vals;
29 : overbeek 1.1 foreach $file (@files)
30 :     {
31 :     open(FILE,"<$upload_dir/$user/$file")
32 :     || die "could not open $upload_dir/$user/$file";
33 :     while (defined($_ = <FILE>))
34 :     {
35 :     chomp;
36 :     my($id,$function,undef,$url) = split(/\t/,$_);
37 : overbeek 1.2
38 :     if ($function)
39 : overbeek 1.1 {
40 : overbeek 1.2 $url = defined($url) ? $url : "";
41 :     $vals{"$id\t$user"} = [$function,$url];
42 : overbeek 1.1 }
43 :     else
44 :     {
45 : overbeek 1.2 delete $vals{"$id\t$user"};
46 : overbeek 1.1 }
47 :     }
48 :     close(FILE);
49 :     }
50 : overbeek 1.2
51 :     my $pair;
52 :     foreach $pair (sort keys(%vals))
53 :     {
54 :     my($id,$user) = split(/\t/,$pair);
55 :     my($function,$url) = @{$vals{$pair}};
56 : overbeek 1.3 # print STDERR "id=$id user=$user\n";
57 : overbeek 1.2
58 :     my $md5;
59 :     if ($md5 = $fig->md5_of_peg($id))
60 :     {
61 :     print join("\t",($id,$function,$md5,$user,$url)),"\n";
62 :     }
63 :     else
64 :     {
65 :     print STDERR "no MD5: $id\n";
66 :     }
67 :     }
68 : overbeek 1.1 }
69 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3