[Bio] / FigKernelPackages / RAST_submission.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/RAST_submission.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Tue Oct 20 20:43:30 2009 UTC revision 1.3, Wed Oct 21 17:19:31 2009 UTC
# Line 103  Line 103 
103      return $res;      return $res;
104  }  }
105    
106    sub retrieve_RAST_job
107    {
108        my($self, $params) = @_;
109    
110        my $job_id = $params->{-job};
111        my $format = $params->{-format};
112    
113        my $job = $self->rast_dbmaster->Job->init({ id => $job_id });
114    
115        if (!ref($job))
116        {
117            return { status => 'error', error_msg => 'Job not found'};
118        }
119    
120        if (!$self->user_may_access_job($job))
121        {
122            return { status => 'error', error_msg => 'Access denied' };
123        }
124    
125        #
126        # Map the given output format to a file.
127        #
128    
129        my %type_map = (genbank => "%s.gbk",
130                        genbank_stripped => "%s.ec-stripped.gbk",
131                        embl => "%s.embl",
132                        embl_stripped => "%s.ec-stripped.embl",
133                        gff3 => "%s.gff",
134                        gff3_stripped => "%s.ec-stripped.gff",
135                        gtf => "%s.gtf",
136                        rast_tarball => "%s.tgz",
137                        );
138    
139        my $file_pattern = $type_map{lc($format)};
140        if (!defined($file_pattern))
141        {
142            return { status => 'error', error_msg => "Format $format not found" };
143        }
144    
145        #
146        # Find the download file.
147        #
148    
149        my $dir = $job->download_dir();
150        my $file = sprintf($file_pattern, $job->genome_id);
151        my $path = "$dir/$file";
152        if (!open(F, "<", $path))
153        {
154            return { status => 'error', error_msg => "Cannot open download file $path"};
155        }
156    
157        local $/;
158        undef $/;
159        my $txt = <F>;
160        return { status => 'ok', contents => $txt };
161    }
162    
163  sub user_may_access_job  sub user_may_access_job
164  {  {
165      my($self, $job_id) = @_;      my($self, $job_id) = @_;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3