Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings FATAL => 'all';
- use Data::Dumper::Concise;
- use Log::Log4perl ':easy';
- use HTGT::DBFactory;
- use IO::File;
- use Perl6::Slurp;
- use Text::CSV_XS;
- Log::Log4perl->easy_init;
- my $input_file = shift || die "Usage: $0 <input_file> [output_file]\n";
- my $outhandle = @ARGV ? IO::File->new( shift, 'w' ) : \*STDOUT;
- my $csv_parser = Text::CSV_XS->new( { eol => $/ } );
- my $connection = HTGT::DBFactory->connect('eucomm_vector');
- my $resultset = $connection->resultset('WellSummaryByDI')->search_rs(
- [ { 'me.targeted_trap' => 'yes' }, { 'me.pgdgr_distribute' => 'yes' }, ],
- {
- prefetch => { project => 'mgi_gene' },
- distinct => 1,
- columns => [
- qw(pgdgr_plate_name pgdgr_well_name pgdgr_distribute targeted_trap project_id)
- ],
- '+columns' => [qw(mgi_gene.mgi_accession_id project.project_status_id)]
- },
- );
- for my $targvec_name ( slurp $input_file, { chomp => 1 } ) {
- if ( $targvec_name =~ m/^(GRD\d+)_(.+)$/ || $targvec_name =~ m/^(.+)_(\w+)$/ ) {
- my $summary_rs = $resultset->search_rs(
- { pgdgr_plate_name => $1, pgdgr_well_name => $2 } );
- while ( my $summary = $summary_rs->next ) {
- $csv_parser->print(
- $outhandle,
- [
- $targvec_name,
- $summary->project->project_status_id,
- $summary->project->mgi_gene->mgi_accession_id
- ]
- );
- }
- }
- }
- exit 0;
Add Comment
Please, Sign In to add comment