[Bio] / Sprout / DeleteChips.pl Repository:
ViewVC logotype

Annotation of /Sprout/DeleteChips.pl

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 :     #
4 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
5 :     # for Interpretations of Genomes. All Rights Reserved.
6 :     #
7 :     # This file is part of the SEED Toolkit.
8 :     #
9 :     # The SEED Toolkit is free software. You can redistribute
10 :     # it and/or modify it under the terms of the SEED Toolkit
11 :     # Public License.
12 :     #
13 :     # You should have received a copy of the SEED Toolkit Public License
14 :     # along with this program; if not write to the University of Chicago
15 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
16 :     # Genomes at veronika@thefig.info or download a copy from
17 :     # http://www.theseed.org/LICENSE.TXT.
18 :     #
19 :    
20 :     use strict;
21 :     use Tracer;
22 :     use Stats;
23 :     use ERDB;
24 :     use Sapling;
25 :     use SeedUtils;
26 :     use FC;
27 :    
28 :     =head1 DeleteChips Script
29 :    
30 :     =head2 Introduction
31 :    
32 :     DeleteChips [options] id1 id2 ...
33 :    
34 :     Expression Data Delete Script
35 :    
36 :     This script deletes the expression data for the specified genomes. This includes the
37 :     chips and the associated experiments, the coregulations, and the atomic regulons.
38 :    
39 :     =head2 Command-Line Options
40 :    
41 :     =over 4
42 :    
43 :     =item trace
44 :    
45 :     Specifies the tracing level. The higher the tracing level, the more messages
46 :     will appear in the trace log. Use E to specify emergency tracing.
47 :    
48 :     =item user
49 :    
50 :     Name suffix to be used for log files. If omitted, the PID is used.
51 :    
52 :     =item sql
53 :    
54 :     If specified, turns on tracing of SQL activity.
55 :    
56 :     =item background
57 :    
58 :     Save the standard and error output to files. The files will be created
59 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
60 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
61 :     B<user> option above.
62 :    
63 :     =item help
64 :    
65 :     Display this command's parameters and options.
66 :    
67 :     =item warn
68 :    
69 :     Create an event in the RSS feed when an error occurs.
70 :    
71 :     =back
72 :    
73 :     =cut
74 :    
75 :     # Get the command-line options and parameters.
76 :     my ($options, @parameters) = StandardSetup([qw(ERDB Sapling) ],
77 :     {
78 :     trace => ["2", "tracing level"],
79 :     },
80 :     "",
81 :     @ARGV);
82 :     # Set a variable to contain return type information.
83 :     my $rtype;
84 :     # Create the statistics object.
85 :     my $stats = Stats->new();
86 :     my $myStartTime = time();
87 :     # Insure we catch errors.
88 :     eval {
89 :     # Create the SAPLING object.
90 :     my $sap = ERDB::GetDatabase('Sapling');
91 :     # We'll put our list of genomes to process in here.
92 :     my @genomes = @ARGV;
93 :     # Loop through the genomes found.
94 :     for my $genome (@genomes) {
95 :     Trace("Processing genome $genome.") if T(2);
96 :     # First, delete the chips.
97 :     my @ids = $sap->GetFlat("HadResultsProducedBy", "HadResultsProducedBy(from-link) = ?",
98 :     [$genome], 'to-link');
99 :     # Loop through the chips.
100 :     for my $chip (@ids) {
101 :     # Delete this chip.
102 :     Trace("Deleting chip $chip.") if T(2);
103 :     my $subStats = $sap->Delete(Chip => $chip);
104 :     $stats->Accumulate($subStats);
105 :     }
106 :     # Get the atomic regulons.
107 :     @ids = $sap->GetFlat("IsConfiguredBy", "IsConfiguredBy(from-link) = ?",
108 :     [$genome], 'to-link');
109 :     # Loop through the regulons.
110 :     for my $regulon (@ids) {
111 :     # Delete this regulon.
112 :     Trace("Deleting regulon $regulon.") if T(3);
113 :     my $subStats = $sap->Delete(AtomicRegulon => $regulon);
114 :     $stats->Accumulate($subStats);
115 :     }
116 :     # Release the memory for the regulon IDs.
117 :     @ids = ();
118 :     # Delete the coregulations for features.
119 :     Trace("Deleting coregulation coefficients for $genome.") if T(2);
120 :     my $deleteCount = $sap->DeleteLike("IsCoregulatedWith", "IsCoregulatedWith(from-link) LIKE ?",
121 :     ["fig|$genome.%"]);
122 :     $stats->Add(IsCoregulatedWith => $deleteCount);
123 :     # Find this genome's coregulated sets.
124 :     Trace("Searching for coregulated sets in $genome.") if T(2);
125 :     my %ids = map { $_ => 1 } $sap->GetFlat("IsRegulatedWith",
126 :     "IsRegulatedWith(from-link) LIKE ?",
127 :     ["fig|$genome.%"], 'to-link');
128 :     for my $coset (keys %ids) {
129 :     # Delete this coregulated set.
130 :     Trace("Deleting coregulated set $coset.") if T(3);
131 :     my $subStats = $sap->Delete(CoregulatedSet => $coset);
132 :     $stats->Accumulate($subStats);
133 :     }
134 :     }
135 :     };
136 :     if ($@) {
137 :     Trace("Script failed with error: $@") if T(0);
138 :     } else {
139 :     Trace("Script complete.") if T(2);
140 :     }
141 :     # Display the run statistics.
142 :     $stats->Add(duration => (time() - $myStartTime));
143 :     Trace("Statistics for this run:\n" . $stats->Show()) if T(2);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3