...
 
Commits (2)
......@@ -9,6 +9,7 @@ use Parse::CPAN::Meta;
use Term::ANSIColor;
use Data::Dumper;
use Time::Piece;
use Excel::Writer::XLSX;
my $usage = <<"HELP";
Usage:
......@@ -22,17 +23,17 @@ Usage:
--client-secret The Client secret you were issued (default: NML IRIDA)
--project-id The particular project ID to check (can specify more than one).
--reference-size The reference genome size (in bp).
--report The filename you'd like to use for writing out the report (default: irida-report.tsv)
--report The filename you'd like to use for writing out the report (default: irida-report.xlsx)
Example:
$0 --username user --reference-size 4000000 --project-id 1
Exports coverage values for the project with identifier 1 to the default file "irida-report.tsv", calculating minimum coverage using a reference genome size of 4,000,000 bp.
Exports coverage values for the project with identifier 1 to the default file "irida-report.xlsx", calculating minimum coverage using a reference genome size of 4,000,000 bp.
$0 --username user --reference-size 3500000 --project-id 3 --project-id 4 --report my-report.tsv
$0 --username user --reference-size 3500000 --project-id 3 --project-id 4 --report my-report.xlsx
Exports coverage values for the projects 3 and 4 to the file "my-report.tsv", calculating minimum coverage using a reference genome size of 3,500,000 bp.
Exports coverage values for the projects 3 and 4 to the file "my-report.xlsx", calculating minimum coverage using a reference genome size of 3,500,000 bp.
HELP
my $api = 'default';
......@@ -40,7 +41,7 @@ my $username;
my $password;
my $client_id = 'default';
my $client_secret = 'default';
my $report_name = "irida-report.tsv";
my $report_name = "irida-report.xlsx";
my $reference_size;
my @project_ids;
my $help;
......@@ -102,9 +103,13 @@ unless ($oauth_access_token) {
my $client = HTTP::Tiny->new( default_headers => {
'Authorization' => "Bearer $oauth_access_token" },
agent => "IRIDA Sample Searcher v1.0 ");
open my $report, '>', $report_name;
my $report_workbook = Excel::Writer::XLSX->new($report_name);
my $report_worksheet = $report_workbook->add_worksheet();
my $header_format = $report_workbook->add_format();
$header_format->set_bold();
print $report "Project Name\tSample Name\tFile Pair\tMean Coverage\tTotal Bases\tReference Size\tProject ID\tSample ID\tFile Pair ID\n";
$report_worksheet->write_row(0,0,['Project Name','Sample Name','Mean Coverage','File Pair','Total Bases','Reference Size','Project ID','Sample ID','File Pair ID'],$header_format);
my $row = 1;
foreach my $project_id (@project_ids) {
my $project_url = "$api/projects/$project_id";
my $project_info = Parse::CPAN::Meta->load_json_string(
......@@ -155,15 +160,8 @@ foreach my $project_id (@project_ids) {
my $file_pair_label = $sequence_file_pair->{'label'};
# Remove whitespace separating file pair labels
$file_pair_label =~ s/\s//g;
# comma to semicolon to less impact defaults for importing CSV
$file_pair_label =~ s/,/;/g;
print $report "$project_info->{'name'}\t$sample->{'sampleName'}\t\"$file_pair_label\"\t$coverage\t$total_bases\t$reference_size\t$project_info->{'identifier'}\t$sample->{'identifier'}\t$sequence_file_pair->{'identifier'}\n";
$report_worksheet->write_row($row,0,[$project_info->{'name'},$sample->{'sampleName'},$coverage,$file_pair_label,$total_bases,$reference_size,$project_info->{'identifier'},$sample->{'identifier'},$sequence_file_pair->{'identifier'}]);
$row++;
}
}
}
close $report;