From 4a45563c2dbba60dfb619058ce2c5ca9b531287d Mon Sep 17 00:00:00 2001 From: Johan Viklund Date: Tue, 2 Nov 2021 14:54:52 +0100 Subject: [PATCH] Remove webapollo from this repo --- annotation/tools/webapollo.md | 1 + .../tools/webapollo/apollo/add-bam-track.pl | 197 ---- .../add_features_from_gff3_to_annotations.pl | 921 ------------------ .../delete_annotations_from_organism.groovy | 84 -- .../apollo/gaas_apollo_track_helper.rb | 168 ---- .../webapollo/apollo/gaas_install_WA_2_0_X.rb | 182 ---- .../webapollo/apollo/gaas_manage_species.rb | 105 -- .../tools/webapollo/apollo/get_cert_first.sh | 4 - annotation/tools/webapollo/apollo/gmod.yaml | 277 ------ annotation/tools/webapollo/apollo/nginx.conf | 125 --- .../tools/webapollo/apollo/refresh_cert.sh | 8 - .../tools/webapollo/apollo/run_proxy.sh | 6 - .../tools/webapollo/apollo/run_webapollo.sh | 35 - annotation/tools/webapollo/apollo/verify.sh | 20 - .../tools/webapollo/apollo/web/index.html | 7 - .../tools/webapollo/apollo1/gaas_add_track.rb | 146 --- .../apollo1/gaas_apollo_track_helper.rb | 168 ---- .../apollo1/gaas_build_template_WA_1_0_X.rb | 79 -- .../apollo1/gaas_new_species_WA_1_0_X.rb | 256 ----- .../webapollo/apollo1/gaas_setup_rakefile.rb | 348 ------- .../webapollo/apollo1/gaas_sync_user_db.rb | 64 -- .../webapollo/apollo1/gaas_transplant.rb | 72 -- .../apollo2/gaas_apollo_track_helper.rb | 172 ---- .../apollo2/gaas_install_WA_2_0_X.rb | 182 ---- .../webapollo/apollo2/gaas_manage_species.rb | 118 --- .../tools/webapollo/terraform/README.md | 39 - .../terraform/localscripts/get-gaas.sh | 13 - .../terraform/localscripts/get-sshkeys.sh | 13 - annotation/tools/webapollo/terraform/main.tf | 197 ---- .../tools/webapollo/terraform/providers.tf | 4 - .../terraform/remotescripts/add-sshkeys.sh | 19 - .../remotescripts/fix_repo_permissions.sh | 7 - .../terraform/remotescripts/install_conda.sh | 14 - .../terraform/remotescripts/install_docker.sh | 11 - .../remotescripts/install_docker_ubuntu16.sh | 6 - .../terraform/remotescripts/mount_volume.sh | 18 - .../terraform/remotescripts/run_docker.sh | 42 - .../webapollo/terraform/terraform.tfvars | 9 - .../tools/webapollo/terraform/variables.tf | 72 -- .../tools/webapollo/terraform/versions.tf | 11 - 40 files changed, 1 insertion(+), 4219 deletions(-) create mode 100644 annotation/tools/webapollo.md delete mode 100755 annotation/tools/webapollo/apollo/add-bam-track.pl delete mode 100755 annotation/tools/webapollo/apollo/add_features_from_gff3_to_annotations.pl delete mode 100755 annotation/tools/webapollo/apollo/delete_annotations_from_organism.groovy delete mode 100755 annotation/tools/webapollo/apollo/gaas_apollo_track_helper.rb delete mode 100755 annotation/tools/webapollo/apollo/gaas_install_WA_2_0_X.rb delete mode 100755 annotation/tools/webapollo/apollo/gaas_manage_species.rb delete mode 100755 annotation/tools/webapollo/apollo/get_cert_first.sh delete mode 100644 annotation/tools/webapollo/apollo/gmod.yaml delete mode 100644 annotation/tools/webapollo/apollo/nginx.conf delete mode 100755 annotation/tools/webapollo/apollo/refresh_cert.sh delete mode 100755 annotation/tools/webapollo/apollo/run_proxy.sh delete mode 100755 annotation/tools/webapollo/apollo/run_webapollo.sh delete mode 100755 annotation/tools/webapollo/apollo/verify.sh delete mode 100644 annotation/tools/webapollo/apollo/web/index.html delete mode 100755 annotation/tools/webapollo/apollo1/gaas_add_track.rb delete mode 100755 annotation/tools/webapollo/apollo1/gaas_apollo_track_helper.rb delete mode 100755 annotation/tools/webapollo/apollo1/gaas_build_template_WA_1_0_X.rb delete mode 100755 annotation/tools/webapollo/apollo1/gaas_new_species_WA_1_0_X.rb delete mode 100755 annotation/tools/webapollo/apollo1/gaas_setup_rakefile.rb delete mode 100755 annotation/tools/webapollo/apollo1/gaas_sync_user_db.rb delete mode 100755 annotation/tools/webapollo/apollo1/gaas_transplant.rb delete mode 100755 annotation/tools/webapollo/apollo2/gaas_apollo_track_helper.rb delete mode 100755 annotation/tools/webapollo/apollo2/gaas_install_WA_2_0_X.rb delete mode 100755 annotation/tools/webapollo/apollo2/gaas_manage_species.rb delete mode 100644 annotation/tools/webapollo/terraform/README.md delete mode 100755 annotation/tools/webapollo/terraform/localscripts/get-gaas.sh delete mode 100755 annotation/tools/webapollo/terraform/localscripts/get-sshkeys.sh delete mode 100644 annotation/tools/webapollo/terraform/main.tf delete mode 100644 annotation/tools/webapollo/terraform/providers.tf delete mode 100755 annotation/tools/webapollo/terraform/remotescripts/add-sshkeys.sh delete mode 100644 annotation/tools/webapollo/terraform/remotescripts/fix_repo_permissions.sh delete mode 100755 annotation/tools/webapollo/terraform/remotescripts/install_conda.sh delete mode 100755 annotation/tools/webapollo/terraform/remotescripts/install_docker.sh delete mode 100755 annotation/tools/webapollo/terraform/remotescripts/install_docker_ubuntu16.sh delete mode 100755 annotation/tools/webapollo/terraform/remotescripts/mount_volume.sh delete mode 100755 annotation/tools/webapollo/terraform/remotescripts/run_docker.sh delete mode 100644 annotation/tools/webapollo/terraform/terraform.tfvars delete mode 100644 annotation/tools/webapollo/terraform/variables.tf delete mode 100644 annotation/tools/webapollo/terraform/versions.tf diff --git a/annotation/tools/webapollo.md b/annotation/tools/webapollo.md new file mode 100644 index 000000000..151cf74ab --- /dev/null +++ b/annotation/tools/webapollo.md @@ -0,0 +1 @@ +Webapollo deployment has moved to the [annotation-cluster](https://github.com/NBISweden/annotation-cluster/) repository. diff --git a/annotation/tools/webapollo/apollo/add-bam-track.pl b/annotation/tools/webapollo/apollo/add-bam-track.pl deleted file mode 100755 index 6a11fedf4..000000000 --- a/annotation/tools/webapollo/apollo/add-bam-track.pl +++ /dev/null @@ -1,197 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; - -use FindBin qw($RealBin); -use lib "$RealBin/../src/perl5"; -use lib $ENV{'CONDA_PREFIX'} . "/opt/jbrowse/src/perl5"; -use JBlibs; - -use Getopt::Long qw(:config no_ignore_case bundling); -use IO::File; -use File::Basename; -use JSON; - -use Pod::Usage; - -my $STORE_CLASS = "JBrowse/Store/SeqFeature/BAM"; -my $ALIGNMENT_TYPE = "JBrowse/View/Track/Alignments2"; -my $COVERAGE_TYPE = "JBrowse/View/Track/SNPCoverage"; - -my $in_file; -my $out_file; -my $label; -my $bam_url; -my $key; -my $coverage = 0; -my $classname = undef; -my $min_score = undef; -my $max_score = undef; - -parse_options(); -add_bam_track(); -exit; - -sub parse_options { - my $help; - GetOptions("in|i=s" => \$in_file, - "out|o=s" => \$out_file, - "label|l=s" => \$label, - "bam_url|u=s" => \$bam_url, - "key|k=s" => \$key, - "classname|c=s" => \$classname, - "coverage|C" => \$coverage, - "min_score|s=i" => \$min_score, - "max_score|S=i" => \$max_score, - "help|h" => \$help); - pod2usage( -verbose => 2 ) if $help; - pod2usage("Missing label option") if !$label; - pod2usage("Missing bam_url option") if !$bam_url; - pod2usage("Missing min_score option") if $coverage && !defined $min_score; - pod2usage("Missing max_score option") if $coverage && !defined $max_score; - $key ||= $label; - $in_file ||= 'data/trackList.json'; - $out_file ||= $in_file; -} - - -sub add_bam_track { - my $json = new JSON; - local $/; - my $in; - $in = new IO::File($in_file) or - die "Error reading input $in_file: $!"; - my $track_list_contents = <$in>; - $in->close(); - my $track_list = $json->decode($track_list_contents); - my $bam_entry; - my $index; - my $tracks = $track_list->{tracks}; - for ($index = 0; $index < scalar(@{$tracks}); ++$index) { - my $track = $tracks->[$index]; - if ($track->{label} eq $label) { - $bam_entry = $track; - last; - } - } - if (!$bam_entry) { - $bam_entry = !$coverage ? generate_new_bam_alignment_entry() : - generate_new_bam_coverage_entry(); - push @{$track_list->{tracks}}, $bam_entry; - } - else { - if ($coverage) { - if ($bam_entry->{type} eq $ALIGNMENT_TYPE) { - $bam_entry = generate_new_bam_coverage_entry(); - $tracks->[$index] = $bam_entry; - } - } - else { - if ($bam_entry->{type} eq $COVERAGE_TYPE) { - $bam_entry = generate_new_bam_alignment_entry(); - $tracks->[$index] = $bam_entry; - } - } - } - $bam_entry->{label} = $label; - $bam_entry->{urlTemplate} = $bam_url; - $bam_entry->{key} = $key; - if (!$coverage) { - if (defined $classname) { - if (! $bam_entry->{style}) { - $bam_entry->{style} = {}; - } - $bam_entry->{style}->{className} = $classname; - } - } - else { - $bam_entry->{min_score} = $min_score; - $bam_entry->{max_score} = $max_score; - } - my $out; - $out = new IO::File($out_file, "w") or - die "Error writing output $out_file: $!"; - print $out $json->pretty->encode($track_list); - $out->close(); -} - -sub generate_new_bam_alignment_entry { - return { - storeClass => $STORE_CLASS, - type => $ALIGNMENT_TYPE, - }; -} - -sub generate_new_bam_coverage_entry { - return { - storeClass => $STORE_CLASS, - type => $COVERAGE_TYPE - }; -} - -__END__ - - -=head1 NAME - -add_bam_track.pl - add track configuration snippet(s) for BAM track(s) - -=cut - -=head1 USAGE - - add_bam_track.pl - [ --in ] \ - [ --out \ - --label \ - --bam_url \ - [ --key ] \ - [ --classname ] \ - [ --coverage ] \ - [ --min_score ] \ - [ --max_score ] \ - [ --help ] - -=head1 ARGUMENTS - -=over 4 - -=item --in - -input trackList.json file. Default: data/trackList.json. - -=item --out - -Output trackList.json file. Default: data/trackList.json. - -=item --bam_url - -URL to BAM file (can be a relative path) - -=item --label - -unique track label for the new track. - -=item --key - -key (display name) for track [default: label value] - -=item --classname - -CSS class for display [default: bam] - -=item --coverage - -display coverage data instead of alignments - -=item --min_score - -optional minimum score to use for generating coverage plot (only applicable with --coverage option) - -=item --max_score - -optional maximum score to use for generating coverage plot (only applicable with --coverage option) - -=back - -=cut diff --git a/annotation/tools/webapollo/apollo/add_features_from_gff3_to_annotations.pl b/annotation/tools/webapollo/apollo/add_features_from_gff3_to_annotations.pl deleted file mode 100755 index 9bc5ca487..000000000 --- a/annotation/tools/webapollo/apollo/add_features_from_gff3_to_annotations.pl +++ /dev/null @@ -1,921 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; - -use FindBin qw($RealBin); -use lib $ENV{'CONDA_PREFIX'} . "/opt/jbrowse/src/perl5"; -use JBlibs; - -use File::Basename; -use lib dirname($0); - -use Bio::GFF3::LowLevel::Parser; -use Getopt::Long qw(:config no_ignore_case bundling); -use IO::File; -use LWP::UserAgent; -use JSON; -use Data::Dumper; - -my $gene_types_in = "gene"; -my $pseudogene_types_in = "pseudogene"; -my $transcript_types_in = "transcript|mRNA"; -my $noncoding_rna_types = "ncRNA|rRNA|tRNA|snRNA|snoRNA|miRNA"; -my $exon_types_in = "exon"; -my $cds_types_in = "CDS"; -my $ontology = "sequence"; -my $gene_type_out = "gene"; -my $pseudogene_type_out = "pseudogene"; -my $mrna_type_out = "mRNA"; -my $transcript_type_out = "transcript"; -my $exon_type_out = "exon"; -my $cds_type_out = "CDS"; -my $sequence_alteration_types = "insertion|deletion|substitution"; -my $annotation_track_prefix = ""; -my $property_ontology = "feature_property"; -my $comment_type_out = "comment"; -my $property_type_out = "feature_property"; -my $disable_cds_recalculation = 0; -my $organism; -my $in = \*STDIN; -my $username; -my $password; -my $url; -my $session_id; -my $name_attributes="Name"; -my $test = 0; -my $use_name_for_feature = 0; - -my $success_log; -my $error_log; - -my $chunk_size = 100; - -my $json = new JSON(); -my $ua = new LWP::UserAgent(); -$ua->timeout(3000); # 5 minutes - -my %source_features = (); -my %skip_ids = (); - -my %reserved_properties = ( symbol => 1, - description => 1, - status => 1 - ); -my %ignored_properties = ( owner => 1, - date_creation => 1, - date_last_modified => 1 - ); - -$| = 1; - -parse_options(); -process_gff(); - -sub parse_options { - my $help; - my $input_file; - my $success_log_file; - my $error_log_file; - my $skip_file; - GetOptions("input|i=s" => \$input_file, - "username|u=s" => \$username, - "password|p=s" => \$password, - "url|U=s" => \$url, - "gene_types_in|g=s" => \$gene_types_in, - "pseudogene_type_in|n=s" => \$pseudogene_types_in, - "transcript_types_in|t=s" => \$transcript_types_in, - "exon_types_in|e=s" => \$exon_types_in, - "organism|o=s" => \$organism, - "cds_types_in|d=s" => \$cds_types_in, - "ontology|O=s" => \$ontology, - "gene_type_out|G=s" => \$gene_type_out, - "pseudogene_type_out|N=s" => \$pseudogene_type_out, - "mrna_type_out|M=s" => \$mrna_type_out, - "transcript_type_out|T=s" => \$transcript_type_out, - "exon_type_out|E=s" => \$exon_type_out, - "cds_type_out|D=s" => \$cds_type_out, - "property_ontolgy|R=s" => \$property_ontology, - "comment_type_out|C=s" => \$comment_type_out, - "property_type_out|S=s" => \$property_type_out, - "track_prefix|P=s" => \$annotation_track_prefix, - "disable_cds_recalculation|X" => \$disable_cds_recalculation, - "success_log|l=s" => \$success_log_file, - "error_log|L=s" => \$error_log_file, - "skip|s=s" => \$skip_file, - "test|x" => \$test, - "help|h" => \$help, - "name_attributes=s" => \$name_attributes, - "use_name_for_feature|a" => \$use_name_for_feature); - - print_usage() if $help; - $in = new IO::File($input_file) or die "Error reading $input_file: $!\n" - if $input_file; - $success_log = new IO::File($success_log_file, "w") or die "Error writing success log $success_log_file: $!\n" if $success_log_file; - $error_log = new IO::File($error_log_file, "w") or die "Error writing error log $error_log_file: $!\n" if $error_log_file; - if ($skip_file) { - my $fh = new IO::File($skip_file) or die "Error reading $skip_file: $!\n"; - while (my $id = <$fh>) { - chomp $id; - ++$skip_ids{$id}; - } - } - print_usage() if(!$username && !$password && !$url); - die "Missing required parameter: username\n" if !$username; - die "Missing required parameter: password\n" if !$password; - die "Missing required parameter: url\n" if !$url; - $url = "http://$url" if $url !~ m%https?://%; -} - -sub print_usage { - my $progname = basename($0); - die << "END"; - -usage: $progname - --url|-U - --username|-u - --password|-p - [--genes_types_in|-g ] - [--pseudogene_type_in|-n ] - [--transcript_types_in|-t ] - [--exon_types_in|-e ] - [--cds_types_in|-d ] - [--ontology|-O ] - [--gene_type_out|-G ] - [--pseudogene_type_out|-N ] - [--mrna_type_out|-T ] - [--transcript_type_out|-T ] - [--exon_type_out|-E ] - [--cds_type_out|-D ] - [--property_ontology|-R ] - [--comment_type_out|-C ] - [--property_type_out|-S ] - [--track_prefix|-P ] - [--disable_cds_recalculation|-X] - [--input|-i ] - [--organism|-o ] - [--success_log|-l ] - [--error_log|-L ] - [--skip|-s ] - [--test|-x] - [--help|-h] - [--name_attributes ] - [--use_name_for_feature|-a] - - U: URL to Apollo instance - u: username to access Apollo - p: password to access Apollo - g: string/regex to define the GFF3 types to treat as genes - [default: "$gene_types_in"] - n: string/regex to define the GFF3 types to treat as pseudogenes - [default: "$pseudogene_types_in"] - t: string/regex to define the GFF3 types to treat as transcripts - [default: "$transcript_types_in"] - e: string/regex to define the GFF3 types to treat as exons - [default: "$exon_types_in"] - d: string/regex to define the GFF3 types to treat as CDS - [default: "$cds_types_in"] - O: ontology name used in Apollo instance - [default: "$ontology"] - G: gene type used in Apollo instance - [default: "$gene_type_out"] - N: pseudogene type used in Apollo instance - [default: "$pseudogene_type_out"] - M: mRNA type used in Apollo instance - [default: "$mrna_type_out"] - T: transcript type used in Apollo instance - [default: "$transcript_type_out"] - E: exon type used in Apollo instance - [default: "$exon_type_out"] - D: CDS type used in Apollo instance - [default: "$cds_type_out"] - R: property ontology name used in Apollo instance - [default: "$property_ontology"] - C: comment type used in Apollo instance - [default: "$comment_type_out"] - S: feature property type used in Apollo instance - [default: "$property_type_out"] - P: annotation track prefix - [default: "$annotation_track_prefix"] - X: disable the recalculation of CDS by Apollo for protein coding features - i: input GFF3 file - [default: STDIN] - o: organism common name in Apollo instance - a: preserve feature names, as-is, in Apollo - l: log file for ids that were successfully processed - L: log file for ids that were erroneously processed - s: file with ids to skip - x: test mode - h: this help screen -END -} - -sub process_gff { - my $gffio = Bio::GFF3::LowLevel::Parser->open($in); - my $seq_ids_to_transcripts = {}; - my $seq_ids_to_genes = {}; - my $seq_ids_to_sequence_alterations = {}; - - while (my $features = $gffio->next_item()) { - next if ref $features ne "ARRAY"; - process_gff_entry($features, $seq_ids_to_genes, $seq_ids_to_transcripts, $seq_ids_to_sequence_alterations); - } - if ($test) { - print "["; - if (keys %{$seq_ids_to_genes} > 0) { - print_features($seq_ids_to_genes, "addFeature"); - } - if (keys %{$seq_ids_to_transcripts}) { - if (keys %{$seq_ids_to_genes} > 0) { - print ","; - } - print_features($seq_ids_to_transcripts, "addTranscript"); - } - if (keys %{$seq_ids_to_sequence_alterations}) { - if (keys %{$seq_ids_to_sequence_alterations} > 0) { - print ","; - } - print_features($seq_ids_to_sequence_alterations, "addSequenceAlteration"); - } - print "]"; - } - else { - write_features("addFeature", $seq_ids_to_genes); - write_features("addTranscript", $seq_ids_to_transcripts); - write_features("addSequenceAlteration", $seq_ids_to_sequence_alterations); - if (!scalar(keys(%{$seq_ids_to_genes})) && !scalar(keys(%{$seq_ids_to_transcripts})) && !scalar(keys(%{$seq_ids_to_sequence_alterations}))) { - print "No genes of type \"$gene_types_in\" or transcripts of type \"$transcript_types_in\" or sequence alterations of type \"$sequence_alteration_types\" found\n"; - } - } - -} - -sub write_features { - my $operation = shift; - my $data = shift; - while (my ($seq_id, $features) = each(%{$data})) { - print "Processing $seq_id\n"; - my @to_be_written = (); - my @ids = (); - my @error = (); - my $chunk = 0; - for (my $i = 0; $i < scalar(@{$features}); ++$i) { - my $feature = $features->[$i]; - push @to_be_written, $feature->[0]; - push @ids, $feature->[1]; - if (($i + 1) % $chunk_size == 0 || $i == scalar(@{$features}) - 1) { - print "Processing chunk " . ++$chunk . ": "; - my $res = send_request($seq_id, $operation, \@to_be_written); - if ($res->{error}) { - print "error: $res->{error}\n"; - for (my $j = 0; $j < scalar(@to_be_written); ++$j) { - push @error, [$to_be_written[$j], $ids[$j]]; - } - } - else { - print "success\n"; - foreach my $id (@ids) { - print $success_log "$id\n" if $success_log; - } - } - @to_be_written = (); - @ids = (); - } - } - if (scalar(@error)) { - print "Processing individual features for failed chunks\n"; - foreach my $feature (@error) { - print "Processing $feature->[1]: "; - my $res = send_request($seq_id, $operation, [$feature->[0]]); - if ($res->{error}) { - print "error: $res->{error}\n"; - print $error_log "$feature->[1]\n" if $error_log; - } - else { - print "success\n"; - print $success_log "$feature->[1]\n" if $success_log; - } - } - } - } -} - -sub convert_feature { - my $features = shift; - my $type = shift; - my $name_attributes = shift; - my $start = get_start($features); - my $end = get_end($features); - my $strand = get_strand($features); - my $name = get_name($features,$name_attributes); - my $comments = get_comments($features); - my $dbxrefs = get_dbxrefs($features); - my $ontology_terms = get_ontology_terms($features); - my $json_feature = { - location => { - fmin => $start - 1, - fmax => $end, - strand => $strand - }, - type => { - cv => { - name => $ontology - }, - name => $type - } - }; - if ($name) { - $json_feature->{name} = $name; - } - my $json_properties = []; - foreach my $comment (@{$comments}) { - my $json_comment = { - value => $comment, - type => { - cv => { - name => $property_ontology - }, - name => $comment_type_out - } - }; - push @{$json_properties}, $json_comment; - } - foreach my $feature (@{$features}) { - while (my ($tag, $values) = each(%{$feature->{attributes}})) { - next if $tag =~ /^[A-Z]/; - next if $ignored_properties{$tag}; - if ($tag =~ /symbol/) { - $json_feature->{symbol} = $values->[0]; - next; - } - if ($tag =~ /description/) { - $json_feature->{description} = $values->[0]; - next; - } - - my $type = $tag; - foreach my $value (@{$values}) { - my $json_property = { - value => $value, - type => { - cv => { - name => $property_ontology - }, - name => $type - } - }; - push @{$json_properties}, $json_property; - } - } - if (scalar(@{$json_properties})) { - $json_feature->{properties} = $json_properties; - } - } - my $json_dbxrefs = []; - foreach my $dbxref (@{$dbxrefs}) { - my ($db, $accession) = split ":", $dbxref; - my $json_dbxref = { - accession => $accession, - db => { - name => $db - } - }; - push @{$json_dbxrefs}, $json_dbxref; - } - foreach my $ontology_term (@{$ontology_terms}) { - my @ontology_term_parts = split /:/, $ontology_term; - my $json_ontology_term = { - accession => $ontology_term_parts[1], - db => { - name => $ontology_term_parts[0] - } - }; - push @{$json_dbxrefs}, $json_ontology_term; - } - if (scalar(@{$dbxrefs})) { - $json_feature->{dbxrefs} = $json_dbxrefs; - } - return $json_feature; -} - -sub convert_sequence_alteration { - my $features = shift; - my $type = shift; - my $name_attributes = shift; - my $start = get_start($features); - my $end = get_end($features); - my $strand = get_strand($features); - #my $name = get_name($features,$name_attributes); - my $comments = get_comments($features); - - if ($type =~ /insertion/) { - $start--; - $end--; - } - else { - $start--; - } - - my $json_feature = { - location => { - fmin => $start, - fmax => $end, - strand => $strand - }, - type => { - cv => { - name => $ontology - }, - name => $type - } - }; - - #if ($name) { - # $json_feature->{name} = $name; - #} - - my $json_properties = []; - foreach my $comment (@{$comments}) { - my $json_comment = { - value => $comment, - type => { - cv => { - name => $property_ontology - }, - name => $comment_type_out - } - }; - push @{$json_properties}, $json_comment; - } - - - foreach my $feature(@{$features}) { - while (my ($tag, $values) = each(%{$feature->{attributes}})) { - next if $tag =~ /^[A-Z]/; - next if $ignored_properties{$tag}; - if ($tag =~ /residues/) { - $json_feature->{residues} = $values->[0]; - next; - } - - my $type = $tag; - foreach my $value (@{$values}) { - my $json_property = { - value => $value, - type => { - cv => { - name => $property_ontology - }, - name => $type - } - }; - push @{$json_properties}, $json_property; - } - } - if (scalar(@{$json_properties})) { - $json_feature->{properties} = $json_properties; - } - } - return $json_feature; -} - -sub get_editor_url { - my $cleanurl = $url =~ s,/*$,,; - return "$url/annotationEditor"; -} - - -sub send_request { - my $seq_id = shift; - my $operation = shift; - my $features = shift; - my $request = { - track => "$annotation_track_prefix$seq_id", - operation => $operation, - username => $username, - password => $password - }; - if($organism) { - $request->{organism}= $organism; - } - - if ($features) { - foreach my $feature (@{$features}) { - push(@{$request->{features}}, $feature); - } - } - my $req = new HTTP::Request(); - $req->method("POST"); - - my $newurl = get_editor_url(); - $newurl = "$newurl/$operation"; - print "$newurl \n"; - $req->uri($newurl); - $req->content($json->encode($request)); - my $res = $ua->request($req); - if ($res->is_success()) { - return $json->decode($res->content()); - } - else { - my $content; - my $message; - eval { - $content = $json->decode($res->content()); - }; - if ($@) { - $message = $res->status_line; - } - else { - $message = $content->{error} ? $content->{error} : $res->status_line; - } - return { error => $message }; - } -} - -sub get_name { - my $features = shift; - my $name_attributes = shift; - my @attrs = split /\|/, $name_attributes; - my $name; - ATTR: - foreach my $attr (@attrs) { - $name = $features->[0]->{attributes}->{$attr}->[0]; - last ATTR unless !$name; - } - return $name; -} - -sub get_comments { - my $features = shift; - my @comments; - foreach my $feature (@{$features}) { - my $values = $feature->{attributes}->{Note}; - push @comments, @{$values} if $values; - } - return \@comments; -} - -sub get_dbxrefs { - my $features = shift; - my @dbxrefs; - foreach my $feature (@{$features}) { - my $values = $feature->{attributes}->{Dbxref}; - push @dbxrefs, @{$values} if $values; - } - return \@dbxrefs; -} - -sub get_ontology_terms { - my $features = shift; - my @ontology_terms; - foreach my $feature (@{$features}) { - my $values = $feature->{attributes}->{Ontology_term}; - push @ontology_terms, @{$values} if $values; - } - return \@ontology_terms; -} - -sub get_seq_id { - my $features = shift; - return $features->[0]->{seq_id}; -} - -sub get_start { - my $features = shift; - my $start = undef; - foreach my $feature (@{$features}) { - if (!defined $start || $feature->{start} < $start) { - $start = $feature->{start}; - } - } - return int($start); -} - -sub get_end { - my $features = shift; - my $end = undef; - foreach my $feature (@{$features}) { - if (!defined $end || $feature->{end} > $end) { - $end = $feature->{end}; - } - } - return int($end); -} - -sub get_strand { - my $features = shift; - my $strand = $features->[0]->{strand}; - if (!defined $strand) { - $strand = "." - } - if ($strand eq "+") { - return 1; - } - elsif ($strand eq "-") { - return -1; - } - return 0; -} - -sub get_id { - my $features = shift; - return $features->[0]->{attributes}->{ID}->[0]; -} - -sub get_type { - my $features = shift; - return $features->[0]->{type}; -} - -sub process_gene { - my $features = shift; - my $gene_type = get_type($features); - my $gene; - if ($gene_type =~ $pseudogene_types_in) { - $gene = convert_feature($features, $pseudogene_type_out, $name_attributes); - } - else { - $gene = convert_feature($features, $gene_type_out, $name_attributes); - } - if ($use_name_for_feature) { - $gene->{use_name} = "true"; - } - my $subfeatures = get_subfeatures($features); - foreach my $subfeature (@{$subfeatures}) { - my $type = get_type($subfeature); - if ($type =~ /$transcript_types_in/) { - my $transcript = process_transcript($subfeature); - push(@{$gene->{children}}, $transcript) if $transcript; - } - elsif ($type =~ /$noncoding_rna_types/) { - my $rna = process_rna($subfeature); - push(@{$gene->{children}}, $rna) if $rna; - } - } - return $gene; -} - -sub process_transcript { - my $features = shift; - my $original_type = get_type($features); - my $transcript; - if ($original_type =~ /transcript/) { - $transcript = convert_feature($features, $transcript_type_out, $name_attributes); - } - else { - $transcript = convert_feature($features, $mrna_type_out, $name_attributes); - } - - if ($use_name_for_feature) { - $transcript->{use_name} = "true"; - } - my $cds_feature = undef; - my $subfeatures = get_subfeatures($features); - foreach my $subfeature (@{$subfeatures}) { - my $type = get_type($subfeature); - if ($type =~ /$exon_types_in/) { - my $exon = convert_feature($subfeature, $exon_type_out,$name_attributes); - push(@{$transcript->{children}}, $exon); - } - elsif ($type =~ /$cds_types_in/) { - my $start = get_start($subfeature); - my $end = get_end($subfeature); - if (!defined $cds_feature) { - $cds_feature = $subfeature; - } - else { - my $cds_start = get_start($cds_feature); - my $cds_end = get_end($cds_feature); - if ($start < $cds_start) { - $cds_feature->[0]->{start} = $start; - } - if ($end > $cds_end) { - $cds_feature->[0]->{end} = $end; - } - } - } - } - if ($cds_feature) { - my $cds = convert_feature($cds_feature, $cds_type_out, $name_attributes); - push(@{$transcript->{children}}, $cds); - } - return $transcript; -} - -sub process_rna { - my $features = shift; - my $type = get_type($features); - my $rna = convert_feature($features, $type, $name_attributes); - if ($use_name_for_feature) { - $rna->{use_name} = "true"; - } - my $subfeatures = get_subfeatures($features); - foreach my $subfeature (@{$subfeatures}) { - my $type = get_type($subfeature); - if ($type =~ /$exon_types_in/) { - my $exon = convert_feature($subfeature, $exon_type_out, $name_attributes); - push(@{$rna->{children}}, $exon); - } - } - return $rna; -} - -sub get_subfeatures { - my @subfeatures; - my $features = shift; - foreach my $feature (@{$features}) { - push @subfeatures, @{$feature->{child_features}}; - } - return \@subfeatures; -} - -sub process_gff_entry { - my $features = shift; - my $seq_ids_to_genes = shift; - my $seq_ids_to_transcripts = shift; - my $seq_ids_to_sequence_alterations = shift; - my $type = get_type($features); - if ($type !~ /$gene_types_in/ && $type !~ /$transcript_types_in/) { - my @subfeatures_array = get_subfeatures($features); - if ($#subfeatures_array) { - foreach my $subfeature (@subfeatures_array) { - process_gff_entry($subfeature, $seq_ids_to_genes, $seq_ids_to_transcripts); - } - } - else { - my @json_features = process_singleton_feature($features); - if (scalar(@json_features) != 0) { - foreach my $json_feature (@json_features) { - my $id = get_id($features); - if ($skip_ids{$id}) { - print "Skipping $id\n"; - next; - } - my $seq_id = get_seq_id($features); - if ($json_feature->{type}->{name} =~ /$sequence_alteration_types/) { - push(@{$seq_ids_to_sequence_alterations->{$seq_id}}, [$json_feature, $id]); - } - else { - push(@{$seq_ids_to_genes->{$seq_id}}, [$json_feature, $id]); - } - } - } - } - - } - else { - my @json_features = @{process_feature($features)}; - if (scalar(@json_features) != 0) { - foreach my $json_feature (@json_features) { - my $id = get_id($features); - if ($skip_ids{$id}) { - print "Skipping $id\n"; - next; - } - my $seq_id = get_seq_id($features); - if ($json_feature->{type}->{name} =~ /$gene_types_in/) { - push(@{$seq_ids_to_genes->{$seq_id}}, [$json_feature, $id]); - } - else { - push(@{$seq_ids_to_transcripts->{$seq_id}}, [$json_feature, $id]); - } - } - } - } -} - -sub process_feature { - my $features = shift; - my $type = get_type($features); - my $transcript_type = get_subfeature_type($features); - - if ($type =~ /$gene_types_in/) { - if ($transcript_type =~ /mRNA/) { - # process with mRNA at top-level and gene information as 'parent' - return process_mrna($features); - } - elsif ($transcript_type =~ /$noncoding_rna_types/) { - # process noncoding RNAs - return [process_gene($features)]; - } - else { - # process top-level - return [process_gene($features)]; - } - } - elsif ($type =~ /$transcript_types_in/) { - return [process_transcript($features)]; - } - return undef; -} - -sub process_singleton_feature { - my $features = shift; - my $type = get_type($features); - my $feature; - if ($type =~ /$sequence_alteration_types/) { - # process sequence alterations - $feature = convert_sequence_alteration($features, $type, $name_attributes); - } - else { - # process other singletons - $feature = convert_feature($features, $type, $name_attributes); - if ($use_name_for_feature) { - $feature->{use_name} = "true"; - } - } - return $feature; -} - -sub get_subfeature_type { - my $features = shift; - return ${features}->[0]->{child_features}->[0]->[0]->{type}; -} - -sub process_mrna { - my $features = shift; - my $gene = convert_feature($features, $gene_type_out, $name_attributes); - my $subfeatures = get_subfeatures($features); - my @processed_mrnas; - - foreach my $subfeature (@{$subfeatures}) { - my $type = get_type($subfeature); - if ($type =~ /mRNA/) { - my $mrna_json_feature = convert_mrna_feature($subfeature, $gene); - push(@processed_mrnas, $mrna_json_feature); - } - } - return \@processed_mrnas; -} - -sub convert_mrna_feature { - my $features = shift; - my $gene_json_feature = shift; - my $cds_feature = undef; - my $rtsc_json_feature = undef; - my $mrna_json_feature = convert_feature($features, $mrna_type_out, $name_attributes); - if ($disable_cds_recalculation) { - $mrna_json_feature->{use_cds} = "true"; - } - if ($use_name_for_feature) { - $mrna_json_feature->{use_name} = "true"; - } - $mrna_json_feature->{parent} = $gene_json_feature; - my $subfeatures = get_subfeatures($features); - - foreach my $subfeature (@{$subfeatures}) { - my $type = get_type($subfeature); - if ($type =~ /$exon_types_in/) { - my $exon = convert_feature($subfeature, $exon_type_out, $name_attributes); - push(@{$mrna_json_feature->{children}}, $exon); - } - elsif ($type =~ /$cds_types_in/) { - my $start = get_start($subfeature); - my $end = get_end($subfeature); - if (!defined $cds_feature) { - $cds_feature = $subfeature; - } - else { - my $cds_start = get_start($cds_feature); - my $cds_end = get_end($cds_feature); - if ($start < $cds_start) { - $cds_feature->[0]->{start} = $start; - } - if ($end > $cds_end) { - $cds_feature->[0]->{end} = $end; - } - } - my $cds_subfeatures = get_subfeatures($cds_feature); - if (scalar(@{$cds_subfeatures}) > 0) { - $rtsc_json_feature = convert_feature(${$cds_subfeatures}[0], "stop_codon_read_through", $name_attributes); - } - } - else { - print "Ignoring unsupported sub-feature type: $type\n"; - } - } - - if ($cds_feature) { - my $cds_json_feature = convert_feature($cds_feature, $cds_type_out, $name_attributes); - push(@{$cds_json_feature->{children}}, $rtsc_json_feature) if ($rtsc_json_feature); - push(@{$mrna_json_feature->{children}}, $cds_json_feature); - } - - return $mrna_json_feature; -} - -sub print_features { - my $data = shift; - my $operation = shift; - while (my ($seq_id, $features) = each(%{$data})) { - my @to_be_written = (); - my @ids = (); - print "{\"$operation\": ["; - for (my $i = 0; $i < scalar(@${features}); ++$i) { - my $feature = $features->[$i]; - print to_json(@$feature[0]); - print "," if ($i != scalar(@$features) - 1); - } - print "]}"; - } -} diff --git a/annotation/tools/webapollo/apollo/delete_annotations_from_organism.groovy b/annotation/tools/webapollo/apollo/delete_annotations_from_organism.groovy deleted file mode 100755 index 5aab974ca..000000000 --- a/annotation/tools/webapollo/apollo/delete_annotations_from_organism.groovy +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env groovy -import groovyjarjarcommonscli.Option -import net.sf.json.JSONArray -import net.sf.json.JSONObject -import groovyx.net.http.RESTClient - -@Grab(group = 'org.json', module = 'json', version = '20140107') -//@Grab(group = 'org.codehaus.groovy.modules.http-builder', module = 'http-builder', version = '0.7.1') -@Grab(group = 'org.codehaus.groovy.modules.http-builder', module = 'http-builder', version = '0.5.2') -@Grab(group = 'org.apache.commons', module = 'commons-lang3', version = '3.0') - -String usageString = "\nUSAGE: delete_annotations_from_organism.groovy \n" + - "Example (will prompt if 'adminusername' and 'adminpassword' are not provided):\n" + - "./delete_annotations_from_organism.groovy -organismname organism_name -destinationurl http://localhost:8080/Apollo\n" + - "./delete_annotations_from_organism.groovy -organismid 123 -sequences chr1,chr2 -destinationurl http://localhost:8080/Apollo -adminusername bob@gov.com -adminpassword demo\n" + - "./delete_annotations_from_organism.groovy -organismid 123 -destinationurl http://localhost:8080/Apollo\n" + - "./delete_annotations_from_organism.groovy -organismid 123 -destinationurl http://localhost:8080/Apollo -adminusername bob@gov.com -adminpassword demo" - -def cli = new CliBuilder(usage: 'delete_annotations_from_organism.groovy') -cli.setStopAtNonOption(true) -cli.organismid('Organism Id corresponding to organism', required: false, args: 1) -cli.organismname('Common name for the organism (if organismid is not provided)', required: false, args:1) -cli.destinationurl('Apollo URL', required: true, args: 1) -cli.sequences('Sequence names from the organism, comma-delimited (e.g., chr1,chr2,chr3)', required: false, args:1) -cli.adminusername('Admin username', required: false, args: 1) -cli.adminpassword('Admin password', required: false, args: 1) -cli.ignoressl('Use this flag to ignore SSL issues', required: false) -OptionAccessor options - -def admin_username -def admin_password - -try { - options = cli.parse(args) - if (!options?.destinationurl) { - println "NOTE: Requires destination URL\n" + usageString - return - } - if (!options?.organismid && !options?.organismname) { - println "NOTE: Requires organismid or organismname as an argument\n" + usageString - return - } - def sysConsole = System.console() - if (!(admin_username=options?.adminusername)) { - admin_username = new String(sysConsole.readLine('Enter admin username: ')) - } - if (!(admin_password=options?.adminpassword)) { - admin_password = new String(sysConsole.readPassword('Enter admin password: ')) - } -} catch(e) { - println(e) - return -} - -def s=options.destinationurl -if (s.endsWith("/")) { - s = s.substring(0, s.length() - 1) -} - -URL url = new URL(s) -def client = new RESTClient(options.destinationurl) -if (options.ignoressl) { client.ignoreSSLIssues() } -String path = "${url.path}/organism/deleteOrganismFeatures" - - -def userArgument = [ - organism: options.organismid ? options.organismid : options.organismname, - username: admin_username, - password: admin_password -] -if(options.sequences){ - userArgument.sequences = options.sequences -} - -def response = client.post( - contentType: 'text/javascript', - path: path, - body: userArgument -) - -if (response.data.error) { - println "Error while deleting features for organism\n${response.data.error}" -} -assert response.status == 200 diff --git a/annotation/tools/webapollo/apollo/gaas_apollo_track_helper.rb b/annotation/tools/webapollo/apollo/gaas_apollo_track_helper.rb deleted file mode 100755 index 9e2acd086..000000000 --- a/annotation/tools/webapollo/apollo/gaas_apollo_track_helper.rb +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# apollo_track_helper.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -g | --gff ] |[ -s | --species ] | -# == DESCRIPTION -# A script to manage tracks for a WebApollo installation -# -# == OPTIONS -# -h,--help:: Show help -# -s,--species=SPECIES:: Name of the species -# -g,--gff=GFF:: Annotation file to process (optional) -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -opts.on("-i","--infile", "=INFILE","Input") {|argument| options.infile = argument } -opts.on("-r","--remove", "Remove track, requires species (-s) and label (-l)") {|argument| options.remove = true } -opts.on("-s","--species", "=SPECIES","Name of the species") {|argument| options.species = argument } -opts.on("-c","--category", "=CATEGORY","Track category") {|argument| options.category = argument } -opts.on("-l","--label", "=LABEL","Label") {|argument| options.label = argument } -opts.on("-o","--outfile", "=OUTFILE","Output") {|argument| options.outfile = argument } -opts.on("-w","--wa_installation", "=wa_installation_name","path to the WA installation") {|argument| options.wa_installation_name = argument } -opts.on("-d","--direct", "=DIRECT","Direct") {|argument| options.direct = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -### Usernames, passwords and locations - -home = ENV['HOME'] - -data_dir = ENV['APOLLO_DATA_DIR'] or abort "Environment vairable APOLLO_DATA_DIR not set" - -config = { - :web_apollo_data => "#{data_dir}/#{options.species}" # Location of the data store for this species -} - -### The workflow - -tracks = { "protein" => "\"match_part\": \"blue-80pct\"" , - "est" => "\"match_part\": \"green-80pct\"" , - "repeat" => "\"match_part\": \"green-80pct\"" , - "tRNA" => "\"exon\": \"green-80pct\"", - "ncRNA" => "\"exon\": \"green-80pct\"", - "synteny" => "\"nucleotide_motif\": \"springgreen-80pct\"", - "rnaseq_match" => "\"match_part\": \"orange-80pct\"" , - "rnaseq" => "\"exon\" : \"green-80pct\"", - "abinito" => "\"match_part\": \"springgreen-80pct\"", - "gene" => "\"wholeCDS\": null, \"CDS\": \"blueviolet-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"", - "lift-over" => "\"wholeCDS\": null, \"CDS\": \"green-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"" - } - - -abort "No species provided" unless options.species -raise "This species (#{options.species}) does not have a build directory under #{config[:web_apollo_data]})" unless File.directory?(config[:web_apollo_data]) -abort "No track label provided" unless options.label - -if options.remove - - system("remove-track.pl --dir #{config[:web_apollo_data]} --trackLabel #{options.label} -D") - -else - - abort "No track provided" if options.infile.nil? - abort "Must provide a category for this track" unless options.category - abort "A track with the label (#{options.label}) already exits for the species (#{options.species})." if File.directory?("#{config[:web_apollo_data]}/tracks/#{options.label}") - - ## Some useful variables - - track = nil - track_number = {} - proceed = false - failure = 0 - - ## - - # List the current information - puts "Your data:" - puts "----------" - puts "Track to load: #{options.infile}" - puts "Track label: #{options.label}" - puts "Category: #{options.category}" - puts "Track type selection..." - puts - - # Ask about the type of data - - - while proceed == false - - abort "Can't make up your mind, eh? Aborting..." if failure > 3 - - puts "###############################################" - puts "Choose the track type from the following list:" - - number = 0 - - tracks.sort_by{|t,f| t}.each do |track_type,formatting| - number += 1 - track_number[number] = track_type - track = track_type - puts "\t#{number}\t#{track_type}" - end - - puts "##############################################" - - - if options.direct - selection = options.direct - proceed = true - track = track_number[selection.to_i] - else - puts "Enter the number corresponding to your choice:" - selection = gets.chomp - - next unless track_number.has_key?(selection.to_i) - - puts "You selected: #{track_number[selection.to_i]} - is that correct? (Y/N)" - - answer = gets.chomp - - if answer.downcase == "y" - proceed = true - track = track_number[selection.to_i] - else - failure += 1 - end - end - - end - - puts "Loading track as type #{track}, with the label #{options.label} into the category #{options.category} of webapollo" - -unless options.direct - puts "Proceed? (Y/N)" - - answer = gets.chomp - - abort "Aborting..." unless answer.downcase == "y" -end - - if track == "gene" or track == "lift-over" or track == "rnaseq" - system "flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type mRNA --trackLabel #{options.label}" - elsif track == "tRNA" - system "flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type tRNA --trackLabel #{options.label}" - elsif track == "ncRNA" - system "flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type ncRNA --trackLabel #{options.label}" - else - system "flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --trackLabel #{options.label}" - end - -end diff --git a/annotation/tools/webapollo/apollo/gaas_install_WA_2_0_X.rb b/annotation/tools/webapollo/apollo/gaas_install_WA_2_0_X.rb deleted file mode 100755 index 980199d7e..000000000 --- a/annotation/tools/webapollo/apollo/gaas_install_WA_2_0_X.rb +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# build.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# A script to build a new WebApollo installation (version 2.0 and up) -# You only need to do this once - Managing species will then be done directly from web interface -# -# == OPTIONS -# -h,--help:: Show help -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Jacques Dainat, jacques.dainat@nbis.se - -require 'optparse' -require 'ostruct' - -#################################### -### Define modules and classes here - -def tomcat_group - - user_groups = `id` - user_groups.include?("tomcat") - -end - -def parse_apollo_config(file,config) - parsed_content = [] - f = File.open(file,"r") - while (line = f.gets) - if line.include?("url =") - line.gsub!(/"jdbc:postgresql:\/\/localhost\/apollo.*"/, "\"jdbc:postgresql://localhost/#{config[:web_apollo_db]}\"") - elsif line.include?("username =") - line.gsub!(//, "#{config[:pguser]}") - elsif line.include?("password =") - line.gsub!(//, "#{config[:pgpass]}") - end - - parsed_content << line - - end - f.close - parsed_content.compact! - - o = File.new(file, "w+") - o.puts parsed_content - o.close - -end - -#################################################### -### Get the script arguments and open relevant files - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -options.clean = false -opts.on("-n","--name", "=NAME","name of the installation") {|argument| options.name = argument } -opts.on("-c","--[no]clean","Clean up the installation") { options.clean = true } -opts.on("-t","--table","=INTEGER","Codon table used. By default it is the table 1") { |argument| options.codonTable = Integer(argument) } -opts.on("-p","--path","=PATH","Define the path to the WA folder to be installed. By default we are looking at: /big/webapollo/release/live_WA_2") { |argument| options.path = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -raise "You are not member of the tomcat group and thus cannot deploy WebApollo!" unless tomcat_group - -@name = options.name or abort 'No Webapollo installation name provided' - -################### -### Usernames, passwords and locations - -user = ENV['USER'] -home = ENV['HOME'] -build_dir = ENV['APOLLO_BUILD_DIR'] or abort "Environment variable APOLLO_BUILD_DIR not set" -user_db_admin = ENV['WA_DB_ADMIN'] or abort "Environment variable WA_PGUSER not set" -user_db_admin_pw = ENV['WA_DB_ADMIN_PW'] or abort "Environment variable WA_PGPASS not set" -tomcat_apps = "/var/lib/tomcat/webapps" # Deployment location - - - -#Define the codon table to use -unless defined?(options.codonTable).nil? # If define we give the default path - if (options.codonTable<1 || options.codonTable>25) - puts "The --table option expects an integer between 1 and 25" - exit - end - if (options.codonTable>1) #We have to add the information to the otpion file - @addCodonString=options.codonTable - end -end - -#Define path to the WA folder -if (defined?(options.path)).nil? # If not define we give the default path - path="/big/webapollo/release/live_WA_2" -else - path=options.path -end - -config = { - :web_apollo_source => "#{path}",# The source code of webapollo - :web_apollo_build => "#{build_dir}/#{@name}", # The location where this WA project is to be build - - :web_apollo_db => "web_apollo_#{@name}", # Name of the user database for this WA project - :pgpass => "#{user_db_admin_pw}", # PW of the SQL WA admin - :pguser => "#{user_db_admin}" # Username of the SQL WA admin -} - - -### The workflow -if options.clean == true - - puts "Are you really sure to erase the whole webapollo installation ( #{tomcat_apps}/#{@name}, #{config[:web_apollo_build]},DB:#{config[:web_apollo_db]} ) ? [y|n]:" - selection = gets.chomp - if(selection.downcase == "y") - puts "Lets remove everything" - - puts "Cleaning webapollo folder" - system("sudo rm -Rf #{config[:web_apollo_build]}") - puts "Cleaning database" -# system("psql -d template1 -U #{config[:pguser]} -c \"DROP DATABASE IF EXISTS #{config[:web_apollo_db]}\"") - system("sudo su - postgres -c \"dropdb #{config[:web_apollo_db]}\"") - puts "Cleaning tomcat folder" - system("rm -f #{tomcat_apps}/#{@name}.war") - system("sudo rm -Rf #{tomcat_apps}/#{@name}") - puts "Cleaning finished" - else - puts "Fine we let everything as it was." - end -else - - File.directory?(config[:web_apollo_source]) or abort "Could not find the reference folder (expected: #{config[:web_apollo_source]})" - abort "Installation already exist. Use flag '--clean' to remove!" if File.directory?(config[:web_apollo_build]) - - # Create the folder where the data is to be stored - puts "Create folders" - system("mkdir -p #{config[:web_apollo_build]}") - - # Create a copy of the webapollo code for this installation - puts "Create a copy of the webapollo source" - system("cp -R #{config[:web_apollo_source]}/* #{config[:web_apollo_build]}") - - # Copy the template config files into place and configurate it - puts "rename the config file and configure it properly" - system("cp #{config[:web_apollo_build]}/sample-postgres-apollo-config.groovy #{config[:web_apollo_build]}/apollo-config.groovy") - parse_apollo_config("#{config[:web_apollo_build]}/apollo-config.groovy",config) - if(defined?(addCodonString).nil?) - open("#{config[:web_apollo_build]}/apollo-config.groovy", 'a') { |f| - f << "// default apollo settings\n" - f << "apollo {\n" - f << "get_translation_code = #{@addCodonString}\n" - f << "}\n" - } - end - - #Create a new database for this installation - puts "Create the database #{config[:web_apollo_db]}" - system("sudo su - postgres -c \"createdb -E UTF-8 -O #{config[:pguser]} #{config[:web_apollo_db]}\"") - - - # Build the webapollo installation - Dir.chdir(config[:web_apollo_build]) do - system("./apollo deploy") - end - - # Copy the packaged WebApollo installation to the Tomcat folder - system("cp #{config[:web_apollo_build]}/target/apollo*.war #{tomcat_apps}/#{@name}.war") - - #Final message: - puts "Congratulation ! Installation done. You can retrieve your installation on the webpage http://annotation-prod.scilifelab.se:8080/#{@name}" - -end - diff --git a/annotation/tools/webapollo/apollo/gaas_manage_species.rb b/annotation/tools/webapollo/apollo/gaas_manage_species.rb deleted file mode 100755 index c8497b815..000000000 --- a/annotation/tools/webapollo/apollo/gaas_manage_species.rb +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# build.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# A script to build a new WebApollo installation based on pre-built template -# -# == OPTIONS -# -h,--help:: Show help -# -s,--species=SPECIES:: Name of the species -# -f,--fasta=FASTA:: Genome sequence -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -prog_dir = File.dirname(__FILE__) - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -options.clean = false -opts.on("-s","--species", "=SPECIES","Species name") {|argument| options.species = argument } -opts.on("-f","--fasta", "=FASTA","Fasta file") {|argument| options.fasta = argument } -opts.on("-c","--[no]clean","Clean up project") { options.clean = true } -opts.on("-w","--wa_installation", "=wa_installation_name","path to the WA installation") {|argument| options.wa_installation_name = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -@species = options.species or abort 'No species name provided' -@organism = options.species.split('_')[0].capitalize + ' ' + options.species.split('_')[-1] -@wa_installation_name = options.wa_installation_name or abort 'Name of the WebApollo installation not provided' -if options.clean != true - @fasta = options.fasta or abort 'No genome sequence provided' -end - -# Custom CSS styles needed for WA -CSS_STRING = ".plus-cigarM {\nbackground-color: green; /* color for plus matches */\n}\n\n.minus-cigarM {\nbackground-color: blue; /* color for minus matches */\n}\n" - -### Usernames, passwords and locations - -user = ENV['USER'] -home = ENV['HOME'] - -data_dir = ENV['APOLLO_DATA_DIR'] or abort "Environment vairable APOLLO_DATA_DIR not set" - -web_apollo_storage = "#{data_dir}/#{@species}" # Folder tree where data is stored - -### The workflow - -if options.clean == true - puts "Are you really sure to remove the species folder ? [y|n]:" - selection = STDIN.gets.chomp - if(selection.downcase == "y") - puts "Cleaning database" - system("#{prog_dir}/delete_annotations_from_organism.groovy -destinationurl http://localhost:8888/#{@wa_installation_name} -organismname #{@species}") - - puts "Cleaning webapollo folder" - system("rm -Rf #{web_apollo_storage}") - - puts "Cleaning finished" - else - puts "Fine we let everythong as it was." - end -else - #check if instalation already existing - if File.directory?("#{web_apollo_storage}") - puts "Instalation for species #{@species} already exits !" - exit - else - # Create the folder where the data is to be stored - puts "Create folders" - system("mkdir -p #{web_apollo_storage}") - #system("chgrp -R tomcat #{web_apollo_storage}") # Must be owned by tomcat group - - # Load genome assembly - puts "Loading genome assembly" - system("prepare-refseqs.pl --fasta #{@fasta} --out #{web_apollo_storage}") - - - # Create custom CSS style sheet - f = File.new("#{web_apollo_storage}/custom.css","w") - f.puts CSS_STRING - f.close - - # Build Blat database - puts "Build Blat database" - system("faToTwoBit #{@fasta} #{web_apollo_storage}/blat.2bit") - - end -end - diff --git a/annotation/tools/webapollo/apollo/get_cert_first.sh b/annotation/tools/webapollo/apollo/get_cert_first.sh deleted file mode 100755 index 194ff13c3..000000000 --- a/annotation/tools/webapollo/apollo/get_cert_first.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -certbot certonly --webroot -d webapollo.nbis.se --config-dir ~/certbot/config --logs-dir ~/certbot/logs --work-dir ~/certbot/work - diff --git a/annotation/tools/webapollo/apollo/gmod.yaml b/annotation/tools/webapollo/apollo/gmod.yaml deleted file mode 100644 index 0e3d04293..000000000 --- a/annotation/tools/webapollo/apollo/gmod.yaml +++ /dev/null @@ -1,277 +0,0 @@ -name: gmod -channels: - - bioconda - - defaults -dependencies: - - _libgcc_mutex=0.1=main - - ca-certificates=2020.7.22=0 - - cairo=1.14.12=h8948797_3 - - expat=2.2.9=he6710b0_2 - - fontconfig=2.13.0=h9420a91_0 - - freetype=2.10.2=h5ab3b9f_0 - - fribidi=1.0.10=h7b6447c_0 - - gff3sort=0.1.a1a2bc9=1 - - giflib=5.1.4=h14c3975_1 - - glib=2.63.1=h5a9c865_0 - - graphite2=1.3.14=h23475e2_0 - - graphviz=2.40.1=h21bd128_2 - - harfbuzz=1.8.8=hffaf4a1_0 - - icu=58.2=he6710b0_3 - - jbrowse=1.16.8=pl526hc9558a2_0 - - jpeg=9b=h024ee3a_2 - - libdb=6.1.26=0 - - libffi=3.2.1=hd88cf55_4 - - libgcc=7.2.0=h69d50b8_2 - - libgcc-ng=9.1.0=hdf63c60_0 - - libgd=2.2.5=h0db58fd_3 - - libpng=1.6.37=hbc83047_0 - - libstdcxx-ng=9.1.0=hdf63c60_0 - - libtiff=4.1.0=h2733197_1 - - libuuid=1.0.3=h1bed415_2 - - libwebp=1.0.1=h8e7db2f_0 - - libxcb=1.14=h7b6447c_0 - - libxml2=2.9.10=he19cac6_1 - - libxslt=1.1.34=hc22bd24_0 - - lz4-c=1.9.2=he6710b0_1 - - mysql-connector-c=6.1.6=2 - - openssl=1.0.2u=h7b6447c_0 - - pango=1.42.4=h049681c_0 - - pcre=8.44=he6710b0_0 - - perl=5.26.2=h14c3975_0 - - perl-aceperl=1.92=pl526_2 - - perl-algorithm-munkres=0.08=pl526_1 - - perl-apache-test=1.40=pl526_1 - - perl-app-cpanminus=1.7044=pl526_1 - - perl-appconfig=1.71=pl526_1 - - perl-array-compare=3.0.1=pl526_1 - - perl-autoloader=5.74=pl526_2 - - perl-base=2.23=pl526_1 - - perl-bio-featureio=1.6.905=pl526_2 - - perl-bio-gff3=2.0=pl526_3 - - perl-bio-phylo=0.58=pl526_2 - - perl-bioperl=1.6.924=4 - - perl-bioperl-core=1.007002=pl526_2 - - perl-business-isbn=3.004=pl526_0 - - perl-business-isbn-data=20140910.003=pl526_0 - - perl-cache-cache=1.08=pl526_0 - - perl-capture-tiny=0.48=pl526_0 - - perl-carp=1.38=pl526_3 - - perl-cgi=4.44=pl526h14c3975_1 - - perl-class-inspector=1.34=pl526_0 - - perl-class-load=0.25=pl526_0 - - perl-class-load-xs=0.10=pl526h6bb024c_2 - - perl-class-method-modifiers=2.12=pl526_0 - - perl-clone=0.42=pl526h516909a_0 - - perl-clone-choose=0.010=pl526_0 - - perl-common-sense=3.74=pl526_2 - - perl-compress-raw-zlib=2.087=pl526hc9558a2_0 - - perl-constant=1.33=pl526_1 - - perl-convert-binary-c=0.78=pl526h6bb024c_3 - - perl-convert-binhex=1.125=pl526_1 - - perl-cpan-meta=2.150010=pl526_0 - - perl-cpan-meta-requirements=2.140=pl526_0 - - perl-cpan-meta-yaml=0.018=pl526_0 - - perl-crypt-rc4=2.02=pl526_1 - - perl-data-compare=1.25=pl526_0 - - perl-data-dumper=2.173=pl526_0 - - perl-data-match=0.06=pl526_0 - - perl-data-optlist=0.110=pl526_2 - - perl-data-stag=0.14=pl526_1 - - perl-date-format=2.30=pl526_2 - - perl-db-file=1.852=pl526h14c3975_0 - - perl-dbd-sqlite=1.64=pl526h516909a_0 - - perl-dbi=1.642=pl526_0 - - perl-devel-globaldestruction=0.14=pl526_0 - - perl-devel-overloadinfo=0.005=pl526_0 - - perl-devel-size=0.83=pl526h14c3975_0 - - perl-devel-stacktrace=2.04=pl526_0 - - perl-digest-crc32=0.01=pl526_2 - - perl-digest-hmac=1.03=pl526_3 - - perl-digest-md5=2.55=pl526_0 - - perl-digest-perl-md5=1.9=pl526_1 - - perl-digest-sha1=2.13=pl526h6bb024c_1 - - perl-dist-checkconflicts=0.11=pl526_2 - - perl-dynaloader=1.25=pl526_1 - - perl-email-date-format=1.005=pl526_2 - - perl-encode=2.88=pl526_1 - - perl-encode-locale=1.05=pl526_6 - - perl-error=0.17027=pl526_1 - - perl-eval-closure=0.14=pl526h6bb024c_4 - - perl-exporter=5.72=pl526_1 - - perl-exporter-tiny=1.002001=pl526_0 - - perl-extutils-cbuilder=0.280230=pl526_1 - - perl-extutils-makemaker=7.36=pl526_1 - - perl-extutils-manifest=1.72=pl526_0 - - perl-extutils-parsexs=3.35=pl526_0 - - perl-file-copy-recursive=0.45=pl526h516909a_0 - - perl-file-find-rule=0.34=pl526_5 - - perl-file-listing=6.04=pl526_1 - - perl-file-next=1.16=pl526_1 - - perl-file-path=2.16=pl526_0 - - perl-file-readbackwards=1.05=pl526_1 - - perl-file-slurp-tiny=0.004=pl526_1 - - perl-file-temp=0.2304=pl526_2 - - perl-file-which=1.23=pl526_0 - - perl-font-afm=1.20=pl526_2 - - perl-font-ttf=1.06=pl526_0 - - perl-gd=2.71=pl526he860b03_0 - - perl-getopt-long=2.50=pl526_1 - - perl-graph=0.9704=pl526_1 - - perl-graphviz=2.24=pl526h734ff71_0 - - perl-hash-merge=0.300=pl526_0 - - perl-heap-simple=0.13=pl526_1 - - perl-heap-simple-perl=0.14=pl526_1 - - perl-heap-simple-xs=0.10=pl526h14c3975_2 - - perl-html-element-extended=1.18=pl526_1 - - perl-html-entities-numbered=0.04=pl526_1 - - perl-html-formatter=2.16=pl526_0 - - perl-html-parser=3.72=pl526h6bb024c_5 - - perl-html-tableextract=2.13=pl526_2 - - perl-html-tagset=3.20=pl526_3 - - perl-html-tidy=1.60=pl526_0 - - perl-html-tree=5.07=pl526_1 - - perl-html-treebuilder-xpath=0.14=pl526_1 - - perl-http-cookies=6.04=pl526_0 - - perl-http-daemon=6.01=pl526_1 - - perl-http-date=6.02=pl526_3 - - perl-http-message=6.18=pl526_0 - - perl-http-negotiate=6.01=pl526_3 - - perl-image-info=1.38=pl526_1 - - perl-image-size=3.300=pl526_2 - - perl-io-html=1.001=pl526_2 - - perl-io-sessiondata=1.03=pl526_1 - - perl-io-socket-ssl=2.066=pl526_0 - - perl-io-string=1.08=pl526_3 - - perl-io-stringy=2.111=pl526_1 - - perl-io-tty=1.12=pl526_1 - - perl-io-uncompress-gunzip=2.064=pl526_1 - - perl-ipc-cmd=1.02=pl526_0 - - perl-ipc-run=20180523.0=pl526_0 - - perl-ipc-sharelite=0.17=pl526h6bb024c_1 - - perl-jcode=2.07=pl526_2 - - perl-json=4.02=pl526_0 - - perl-json-pp=4.04=pl526_0 - - perl-json-xs=2.34=pl526h6bb024c_3 - - perl-lib=0.63=pl526_1 - - perl-libwww-perl=6.39=pl526_0 - - perl-libxml-perl=0.08=pl526_2 - - perl-list-moreutils=0.428=pl526_1 - - perl-list-moreutils-xs=0.428=pl526_0 - - perl-local-lib=2.000024=pl526_0 - - perl-locale-maketext-simple=0.21=pl526_2 - - perl-lwp-mediatypes=6.04=pl526_0 - - perl-lwp-protocol-https=6.07=pl526_4 - - perl-lwp-simple=6.15=pl526h470a237_4 - - perl-mailtools=2.21=pl526_0 - - perl-math-cdf=0.1=pl526h14c3975_5 - - perl-math-derivative=1.01=pl526_0 - - perl-math-random=0.72=pl526h14c3975_2 - - perl-math-spline=0.02=pl526_2 - - perl-mime-base64=3.15=pl526_1 - - perl-mime-lite=3.030=pl526_1 - - perl-mime-tools=5.508=pl526_1 - - perl-mime-types=2.17=pl526_0 - - perl-mldbm=2.05=pl526_1 - - perl-module-build=0.4224=pl526_3 - - perl-module-corelist=5.20190524=pl526_0 - - perl-module-implementation=0.09=pl526_2 - - perl-module-load=0.32=pl526_1 - - perl-module-load-conditional=0.68=pl526_2 - - perl-module-metadata=1.000036=pl526_0 - - perl-module-runtime=0.016=pl526_1 - - perl-module-runtime-conflicts=0.003=pl526_0 - - perl-moo=2.003004=pl526_0 - - perl-moose=2.2011=pl526hf484d3e_1 - - perl-mozilla-ca=20180117=pl526_1 - - perl-mro-compat=0.13=pl526_0 - - perl-net-http=6.19=pl526_0 - - perl-net-ssleay=1.85=pl526h9dad42d_0 - - perl-ntlm=1.09=pl526_4 - - perl-number-compare=0.03=pl526_2 - - perl-ole-storage_lite=0.19=pl526_3 - - perl-package-deprecationmanager=0.17=pl526_0 - - perl-package-stash=0.38=pl526hf484d3e_1 - - perl-package-stash-xs=0.28=pl526hf484d3e_1 - - perl-params-check=0.38=pl526_1 - - perl-params-util=1.07=pl526h6bb024c_4 - - perl-parent=0.236=pl526_1 - - perl-parse-recdescent=1.967015=pl526_0 - - perl-pathtools=3.75=pl526h14c3975_1 - - perl-pdf-api2=2.035=pl526_0 - - perl-perl-ostype=1.010=pl526_1 - - perl-perlio-gzip=0.20=pl526h84994c4_1 - - perl-pod-escapes=1.07=pl526_1 - - perl-pod-usage=1.69=pl526_1 - - perl-postscript=0.06=pl526_2 - - perl-role-tiny=2.000008=pl526_0 - - perl-scalar-list-utils=1.52=pl526h516909a_0 - - perl-set-scalar=1.29=pl526_2 - - perl-soap-lite=1.19=pl526_1 - - perl-socket=2.027=pl526_1 - - perl-sort-naturally=1.03=pl526_2 - - perl-spreadsheet-parseexcel=0.65=pl526_2 - - perl-spreadsheet-writeexcel=2.40=pl526_2 - - perl-statistics-descriptive=3.0702=pl526_0 - - perl-storable=3.15=pl526h14c3975_0 - - perl-string-escape=2010.002=pl526_0 - - perl-sub-exporter=0.987=pl526_2 - - perl-sub-exporter-progressive=0.001013=pl526_0 - - perl-sub-identify=0.14=pl526h14c3975_0 - - perl-sub-install=0.928=pl526_2 - - perl-sub-name=0.21=pl526_1 - - perl-sub-quote=2.006003=pl526_1 - - perl-sub-uplevel=0.2800=pl526h14c3975_2 - - perl-svg=2.84=pl526_0 - - perl-svg-graph=0.02=pl526_3 - - perl-task-weaken=1.06=pl526_0 - - perl-template-toolkit=2.26=pl526_1 - - perl-test=1.26=pl526_1 - - perl-test-deep=1.128=pl526_1 - - perl-test-harness=3.42=pl526_0 - - perl-test-leaktrace=0.16=pl526h14c3975_2 - - perl-test-requiresinternet=0.05=pl526_0 - - perl-test-simple=1.302164=pl526_0 - - perl-test-warn=0.36=pl526_1 - - perl-text-abbrev=1.02=pl526_0 - - perl-text-glob=0.11=pl526_1 - - perl-text-parsewords=3.30=pl526_0 - - perl-threaded=5.26.0=0 - - perl-tie-ixhash=1.23=pl526_2 - - perl-time-hires=1.9760=pl526h14c3975_1 - - perl-time-local=1.28=pl526_1 - - perl-timedate=2.30=pl526_1 - - perl-tree-dag_node=1.31=pl526_0 - - perl-try-tiny=0.30=pl526_1 - - perl-type-tiny=1.004004=pl526_0 - - perl-types-serialiser=1.0=pl526_2 - - perl-unicode-map=0.112=pl526h6bb024c_3 - - perl-uri=1.76=pl526_0 - - perl-version=0.9924=pl526_0 - - perl-www-robotrules=6.02=pl526_3 - - perl-xml-dom=1.46=pl526_0 - - perl-xml-dom-xpath=0.14=pl526_1 - - perl-xml-filter-buffertext=1.01=pl526_2 - - perl-xml-libxml=2.0132=pl526h7ec2d77_1 - - perl-xml-libxslt=1.94=pl526_1 - - perl-xml-namespacesupport=1.12=pl526_0 - - perl-xml-parser=2.44=pl526h4e0c4b3_7 - - perl-xml-regexp=0.04=pl526_2 - - perl-xml-sax=1.02=pl526_0 - - perl-xml-sax-base=1.09=pl526_0 - - perl-xml-sax-expat=0.51=pl526_3 - - perl-xml-sax-writer=0.57=pl526_0 - - perl-xml-simple=2.25=pl526_1 - - perl-xml-twig=3.52=pl526_2 - - perl-xml-writer=0.625=pl526_2 - - perl-xml-xpath=1.44=pl526_0 - - perl-xml-xpathengine=0.14=pl526_2 - - perl-xsloader=0.24=pl526_0 - - perl-yaml=1.29=pl526_0 - - pixman=0.40.0=h7b6447c_0 - - tidyp=1.04=h516909a_2 - - ucsc-fatotwobit=366=h5eb252a_0 - - xz=5.2.5=h7b6447c_0 - - zlib=1.2.11=h7b6447c_3 - - zstd=1.4.5=h9ceee32_0 -prefix: /mnt/sequences/conda/envs/gmod - diff --git a/annotation/tools/webapollo/apollo/nginx.conf b/annotation/tools/webapollo/apollo/nginx.conf deleted file mode 100644 index 125c2c727..000000000 --- a/annotation/tools/webapollo/apollo/nginx.conf +++ /dev/null @@ -1,125 +0,0 @@ -user www-data; -worker_processes 1; - -error_log /var/log/nginx/error.log debug; -pid /var/run/nginx.pid; -#daemon off; - -events { - worker_connections 1024; - use epoll; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - access_log /var/log/nginx/access.log; - - keepalive_timeout 9000; - proxy_read_timeout 9000; - sendfile on; - tcp_nopush on; - tcp_nodelay on; - gzip on; - gzip_min_length 1000; - gzip_proxied any; - gzip_types text/plain text/html text/css text/xml - application/x-javascript application/xml - application/atom+xml text/javascript; - - - map $http_upgrade $useorigin { - default $http_origin; - websocket ''; - } - - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $http_connection; - proxy_set_header Origin $useorigin; - - proxy_http_version 1.1; - - - server { - listen 8443 ssl http2; - listen 8080; - - ssl_certificate /config/cert.pem; - ssl_certificate_key /config/key.pem; - #ssl_dhparam /config/dhparam.pem; - root /config/serve; - - location / { - #try_files $uri $uri/ @wsgi =404; - } - - location /larinioides_sclopetarius/ { - # There were issues using the wsgi transport for uwsgi, - # use its built in http server. - proxy_pass http://129.16.123.193:8888/; - proxy_redirect http://129.16.123.193:8888/ https://$host/larinioides_sclopetarius/; - sub_filter '="/assets/' '="https://$host/larinioides_sclopetarius/assets/'; - sub_filter_once off; - } - - - location /agrotis_infusa/ { - # There were issues using the wsgi transport for uwsgi, - # use its built in http server. - proxy_pass http://130.238.29.226:8888/; - proxy_redirect http://130.238.29.226:8888/ https://$host/agrotis_infusa/; - sub_filter '="/assets/' '="https://$host/agrotis_infusa/assets/'; - sub_filter_once off; - } - - location /fusarium_culmorum/ { - # There were issues using the wsgi transport for uwsgi, - # use its built in http server. - proxy_pass http://130.238.28.45:8888/; - proxy_redirect http://130.238.28.45:8888/ https://$host/fusarium_culmorum/; - sub_filter '="/assets/' '="https://$host/fusarium_culmorum/assets/'; - sub_filter_once off; - } - - location /linum_tenue/ { - # There were issues using the wsgi transport for uwsgi, - # use its built in http server. - proxy_pass http://130.239.81.176:8888/; - proxy_redirect http://130.239.81.176:8888/ https://$host/linum_tenue/; - sub_filter '="/assets/' '="https://$host/linum_tenue/assets/'; - sub_filter_once off; - } - - location /elixirannotation2021/ { - # There were issues using the wsgi transport for uwsgi, - # use its built in http server. - proxy_pass http://129.16.123.242:8888/; - proxy_redirect http://129.16.123.242:8888/ https://$host/elixirannotation2021/; - sub_filter '="/assets/' '="https://$host/elixirannotation2021/assets/'; - sub_filter_once off; - } - - location /geodia_baretti/ { - # There were issues using the wsgi transport for uwsgi, - # use its built in http server. - proxy_pass http://130.238.28.200:8888/; - proxy_redirect http://130.238.28.200:8888/ https://$host/geodia_baretti/; - sub_filter '="/assets/' '="https://$host/geodia_baretti/assets/'; - sub_filter_once off; - } - location /linum_tenuev2/ { - # There were issues using the wsgi transport for uwsgi, - # use its built in http server. - proxy_pass http://129.16.123.68:8888/; - proxy_redirect http://129.16.123.68:8888/ https://$host/linum_tenuev2/; - sub_filter '="/assets/' '="https://$host/linum_tenuev2/assets/'; - sub_filter_once off; - } - - - } -} diff --git a/annotation/tools/webapollo/apollo/refresh_cert.sh b/annotation/tools/webapollo/apollo/refresh_cert.sh deleted file mode 100755 index 7abec71f3..000000000 --- a/annotation/tools/webapollo/apollo/refresh_cert.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -certbot renew --webroot --config-dir ~/certbot/config --logs-dir ~/certbot/logs --work-dir ~/certbot/work - -rsync -L ~/certbot/config/live/webapollo.nbis.se/privkey.pem ~/config/key.pem -rsync -L ~/certbot/config/live/webapollo.nbis.se/cert.pem ~/config/cert.pem -rsync -L ~/certbot/config/live/webapollo.nbis.se/fullchain.pem ~/config/ca.pem -sudo pkill -HUP nginx diff --git a/annotation/tools/webapollo/apollo/run_proxy.sh b/annotation/tools/webapollo/apollo/run_proxy.sh deleted file mode 100755 index 522781646..000000000 --- a/annotation/tools/webapollo/apollo/run_proxy.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -here=$(realpath "$(dirname "$0")") -mkdir -p ~/config/serve -rsync -L -au "$here/web/" ~/config/serve/ -docker run --restart unless-stopped -p 80:8080 -p 443:8443 -v ~/config:/config:ro -v "$here/nginx.conf":/etc/nginx/nginx.conf:ro --name nginx -d nginx diff --git a/annotation/tools/webapollo/apollo/run_webapollo.sh b/annotation/tools/webapollo/apollo/run_webapollo.sh deleted file mode 100755 index 628bc836d..000000000 --- a/annotation/tools/webapollo/apollo/run_webapollo.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -here=$(realpath "$(dirname "$0")") - -for s in /mnt/*; do - if [ ! -d "$s" ] ; then - # Ignore non-directories - continue - fi - - if [ ! -e "$s/species" ] ; then - # We need a species file to run here - continue - fi - - species=$(cat "$s/species") - password=$(cat "$here/apolloadminpassword") - port=8888 - catalinaopts=-Xmx14G - - if [ -e "$s/port" ]; then - port=$(cat "$s/port") - fi - if [ -e "$s/apolloadminpassword" ]; then - password=$(cat "$s/apolloadminpassword") - fi - if [ -e "$s/catalinaopts" ]; then - catalinaopts=$(cat "$s/catalinaopts") - fi - - mkdir -p "$s/data" - mkdir -p "$s/postgres-data" - - docker run --restart unless-stopped --name "webapollo-$species" -d -e CATALINA_OPTS="$catalinaopts" -e APOLLO_ADMIN_EMAIL=admin@nbis.se -e APOLLO_ADMIN_PASSWORD="$password" -v "$s/data/":/data -v "$s/postgres-data/":/var/lib/postgresql -p "$port":8080 gmod/apollo:latest -done diff --git a/annotation/tools/webapollo/apollo/verify.sh b/annotation/tools/webapollo/apollo/verify.sh deleted file mode 100755 index be72e4e69..000000000 --- a/annotation/tools/webapollo/apollo/verify.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -if type ruby >/dev/null 2>/dev/null; then - : -else - echo "Missing ruby" -fi - -if type groovy >/dev/null 2>/dev/null; then - : -else - echo "Missing groovy" -fi - -if [ -d "$APOLLO_DATA_DIR" ]; then - : -else - echo "APOLLO_DATA_DIR is not set or does not point to a directory" -fi - diff --git a/annotation/tools/webapollo/apollo/web/index.html b/annotation/tools/webapollo/apollo/web/index.html deleted file mode 100644 index 1926a5c0d..000000000 --- a/annotation/tools/webapollo/apollo/web/index.html +++ /dev/null @@ -1,7 +0,0 @@ - -NBIS webapollo - -

NBIS webapollo

-
Please use the URL you got for your delivery.
- - diff --git a/annotation/tools/webapollo/apollo1/gaas_add_track.rb b/annotation/tools/webapollo/apollo1/gaas_add_track.rb deleted file mode 100755 index f992f2db2..000000000 --- a/annotation/tools/webapollo/apollo1/gaas_add_track.rb +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# add_track.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -g | --gff ] |[ -s | --species ] | -# == DESCRIPTION -# A script to add a track to an existing WebApollo installation. -# -# == OPTIONS -# -h,--help:: Show help -# -s,--species=SPECIES:: Name of the species -# -g,--gff=GFF:: Annotation file to process (optional) -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -opts.on("-i","--infile", "=INFILE","Input") {|argument| options.infile = argument } -opts.on("-s","--species", "=SPECIES","Name of the species") {|argument| options.species = argument } -opts.on("-c","--category", "=CATEGORY","Track category") {|argument| options.category = argument } -opts.on("-l","--label", "=LABEL","Label") {|argument| options.label = argument } -opts.on("-o","--outfile", "=OUTFILE","Output") {|argument| options.outfile = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -### Usernames, passwords and locations - -home = ENV['HOME'] - -config = { - :web_apollo_build => "/big/webapollo/build/#{options.species}", # The location where this WA project is to be build - :web_apollo_data => "/big/data/#{options.species}/data" # Location of the data store for this species -} - -### The workflow - -raise "This species (#{options.species}) does not have a build directory under #{config[:web_apollo_build]})" unless File.directory?(config[:web_apollo_build]) -raise "This species (#{options.species}) does not have a build directory under #{config[:web_apollo_data]})" unless File.directory?(config[:web_apollo_data]) - -tracks = { "protein" => "\"match_part\": \"blue-80pct\"" , - "est" => "\"match_part\": \"green-80pct\"" , - "tRNA" => "\"exon\": \"green-80pct\"", - "ncRNA" => "\"exon\": \"green-80pct\"", - "synteny" => "\"nucleotide_motif\": \"springgreen-80pct\"", - "rnaseq" => "\"match_part\": \"orange-80pct\"" , - "abinito" => "\"match_part\": \"springgreen-80pct\"", - "gene" => "\"wholeCDS\": null, \"CDS\": \"blueviolet-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"", - "lift-over" => "\"wholeCDS\": null, \"CDS\": \"green-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"" - } - -abort "No track provided" if options.infile.nil? -abort "No species provided" unless options.species -abort "Must provide a category for this track" unless options.category -abort "Must provide a label for this track" unless options.label - -## Some useful variables - -track = nil -track_number = {} -proceed = false -failure = 0 - -## - -# List the current information -puts "Your data:" -puts "----------" -puts "Track to load: #{options.infile}" -puts "WebApollo portal: #{config[:web_apollo_build]}" -puts "Track label: #{options.label}" -puts "Category: #{options.category}" -puts "Track type selection..." -puts - -# Ask about the type of data - - -while proceed == false - - abort "Can't make up your mind, eh? Aborting..." if failure > 3 - - puts "###############################################" - puts "Choose the track type from the following list:" - - number = 0 - - tracks.sort_by{|t,f| t}.each do |track_type,formatting| - number += 1 - track_number[number] = track_type - track = track_type - puts "\t#{number}\t#{track_type}" - end - - puts "##############################################" - puts "Enter the number corresponding to your choice:" - - selection = gets.chomp - - next unless track_number.has_key?(selection.to_i) - - puts "You selected: #{track_number[selection.to_i]} - is that correct? (Y/N)" - - answer = gets.chomp - - if answer.downcase == "y" - proceed = true - track = track_number[selection.to_i] - else - failure += 1 - end - - -end - -puts "Loading track as type #{track}, with the label #{options.label} into the category #{options.category} of webapollo directory #{config[:web_apollo_build]}" - -puts "Proceed? (Y/N)" - -answer = gets.chomp - -abort "Aborting..." unless answer.downcase == "y" - -if track == "gene" or track == "lift-over" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type mRNA --trackLabel #{options.label}" -elsif track == "tRNA" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type tRNA --trackLabel #{options.label}" -elsif track == "ncRNA" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type ncRNA --trackLabel #{options.label}" -else - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --trackLabel #{options.label}" -end diff --git a/annotation/tools/webapollo/apollo1/gaas_apollo_track_helper.rb b/annotation/tools/webapollo/apollo1/gaas_apollo_track_helper.rb deleted file mode 100755 index 8571519a7..000000000 --- a/annotation/tools/webapollo/apollo1/gaas_apollo_track_helper.rb +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# apollo_track_helper.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -g | --gff ] |[ -s | --species ] | -# == DESCRIPTION -# A script to manage tracks for a WebApollo installation -# -# == OPTIONS -# -h,--help:: Show help -# -s,--species=SPECIES:: Name of the species -# -g,--gff=GFF:: Annotation file to process (optional) -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -opts.on("-i","--infile", "=INFILE","Input") {|argument| options.infile = argument } -opts.on("-r","--remove", "Remove track, requires species (-s) and label (-l)") {|argument| options.remove = true } -opts.on("-s","--species", "=SPECIES","Name of the species") {|argument| options.species = argument } -opts.on("-c","--category", "=CATEGORY","Track category") {|argument| options.category = argument } -opts.on("-l","--label", "=LABEL","Label") {|argument| options.label = argument } -opts.on("-o","--outfile", "=OUTFILE","Output") {|argument| options.outfile = argument } -opts.on("-d","--direct", "=DIRECT","Direct") {|argument| options.direct = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -### Usernames, passwords and locations - -home = ENV['HOME'] - -build_dir = ENV['APOLLO_BUILD_DIR'] or abort "Environment variable APOLLO_BUILD_DIR not set" -data_dir = ENV['APOLLO_DATA_DIR'] or abort "Environment vairable APOLLO_DATA_DIR not set" - -config = { - :web_apollo_build => "#{build_dir}/#{options.species}", # The location where this WA project is to be build - :web_apollo_data => "#{data_dir}/#{options.species}/data" # Location of the data store for this species -} - -### The workflow - -tracks = { "protein" => "\"match_part\": \"blue-80pct\"" , - "est" => "\"match_part\": \"green-80pct\"" , - "tRNA" => "\"exon\": \"green-80pct\"", - "ncRNA" => "\"exon\": \"green-80pct\"", - "synteny" => "\"nucleotide_motif\": \"springgreen-80pct\"", - "rnaseq" => "\"match_part\": \"orange-80pct\"" , - "abinito" => "\"match_part\": \"springgreen-80pct\"", - "gene" => "\"wholeCDS\": null, \"CDS\": \"blueviolet-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"", - "lift-over" => "\"wholeCDS\": null, \"CDS\": \"green-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"" - } - - -abort "No species provided" unless options.species -raise "This species (#{options.species}) does not have a build directory under #{config[:web_apollo_build]})" unless File.directory?(config[:web_apollo_build]) -raise "This species (#{options.species}) does not have a build directory under #{config[:web_apollo_data]})" unless File.directory?(config[:web_apollo_data]) -abort "No track label provided" unless options.label - -if options.remove - - system("perl #{config[:web_apollo_build]}/bin/remove-track.pl --dir #{config[:web_apollo_data]} --trackLabel #{options.label} -D") - -else - - abort "No track provided" if options.infile.nil? - abort "Must provide a category for this track" unless options.category - - ## Some useful variables - - track = nil - track_number = {} - proceed = false - failure = 0 - - ## - - # List the current information - puts "Your data:" - puts "----------" - puts "Track to load: #{options.infile}" - puts "WebApollo portal: #{config[:web_apollo_build]}" - puts "Track label: #{options.label}" - puts "Category: #{options.category}" - puts "Track type selection..." - puts - - # Ask about the type of data - - - while proceed == false - - abort "Can't make up your mind, eh? Aborting..." if failure > 3 - - puts "###############################################" - puts "Choose the track type from the following list:" - - number = 0 - - tracks.sort_by{|t,f| t}.each do |track_type,formatting| - number += 1 - track_number[number] = track_type - track = track_type - puts "\t#{number}\t#{track_type}" - end - - puts "##############################################" - - - if options.direct - selection = options.direct - proceed = true - track = track_number[selection.to_i] - else - puts "Enter the number corresponding to your choice:" - selection = gets.chomp - - next unless track_number.has_key?(selection.to_i) - - puts "You selected: #{track_number[selection.to_i]} - is that correct? (Y/N)" - - answer = gets.chomp - - if answer.downcase == "y" - proceed = true - track = track_number[selection.to_i] - else - failure += 1 - end - end - - end - - puts "Loading track as type #{track}, with the label #{options.label} into the category #{options.category} of webapollo directory #{config[:web_apollo_build]}" - -unless options.direct - puts "Proceed? (Y/N)" - - answer = gets.chomp - - abort "Aborting..." unless answer.downcase == "y" -end - - if track == "gene" or track == "lift-over" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type mRNA --trackLabel #{options.label}" - elsif track == "tRNA" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type tRNA --trackLabel #{options.label}" - elsif track == "ncRNA" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type ncRNA --trackLabel #{options.label}" - else - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --trackLabel #{options.label}" - end - -end diff --git a/annotation/tools/webapollo/apollo1/gaas_build_template_WA_1_0_X.rb b/annotation/tools/webapollo/apollo1/gaas_build_template_WA_1_0_X.rb deleted file mode 100755 index ed4246760..000000000 --- a/annotation/tools/webapollo/apollo1/gaas_build_template_WA_1_0_X.rb +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# build.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# A script to build a new WebApollo template installation (version 1.0 and up) -# You only need to do this once - the new_species.rb script will then copy this template -# to create new build projects. -# -# == OPTIONS -# -h,--help:: Show help -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -options.clean = false -opts.on("-c","--[no]clean","Clean up project") { options.clean = true } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -### Usernames, passwords and locations - -user = ENV['USER'] -home = ENV['HOME'] -build_dir = ENV['APOLLO_BUILD_DIR'] or abort "Environment variable APOLLO_BUILD_DIR not set" - - -config = { - :web_apollo_source => "/big/webapollo/release/live",# The source code of webapollo - :web_apollo_build => "#{build_dir}/template", # The location where this WA project is to be build -} - -### File targets - -config_files = [ "sample_config.properties" , "sample_config.xml" , "sample_blat_config.xml", "sample_hibernate.xml" ] - -### The workflow - -if options.clean == true - system("rm -Rf #{config[:web_apollo_build]}") - -else - - File.directory?(config[:web_apollo_source]) or abort "Could not find the reference git clone (expected: #{config[:web_apollo_source]})" - abort "Template already exist. Use flag '--clean' to remove!" if File.directory?(config[:web_apollo_build]) - - # Create the folder where the data is to be stored - system("mkdir -p #{config[:web_apollo_build]}") - # Create a copy of the webapollo code for this installation - system("mkdir -p #{config[:web_apollo_build]}") - system("cp -R #{config[:web_apollo_source]}/* #{config[:web_apollo_build]}") - # Copy the template config files into place - config_files.each do |file| - system("cp #{config[:web_apollo_build]}/#{file} #{config[:web_apollo_build]}/#{file.gsub(/sample_/, '')}") - end - # Build the webapollo installation - Dir.chdir(config[:web_apollo_build]) do - system("./apollo deploy") - end - -end - diff --git a/annotation/tools/webapollo/apollo1/gaas_new_species_WA_1_0_X.rb b/annotation/tools/webapollo/apollo1/gaas_new_species_WA_1_0_X.rb deleted file mode 100755 index 7cdcdc3da..000000000 --- a/annotation/tools/webapollo/apollo1/gaas_new_species_WA_1_0_X.rb +++ /dev/null @@ -1,256 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# build.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# A script to build a new WebApollo installation based on pre-built template -# -# == OPTIONS -# -h,--help:: Show help -# -s,--species=SPECIES:: Name of the species -# -g,--gff=GFF:: Annotation file to process (optional) -# -f,--fasta=FASTA:: Genome sequence -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -def tomcat_group - - user_groups = `id` - user_groups.include?("tomcat") - -end - -def parse_config_xml(file,config) - - parsed_content = [] - f = File.open(file,"r") - while (line = f.gets) - - if line.include?("ENTER_DATASTORE_DIRECTORY_HERE") - line.gsub!(/ENTER_DATASTORE_DIRECTORY_HERE/, config[:data_dir]) - elsif line.include?("jdbc:postgresql:web_apollo_users") - line.gsub!(/jdbc:postgresql:web_apollo_users/, "jdbc:postgresql://localhost/#{config[:web_apollo_user_db]}") - elsif line.include?("ENTER_USER_DATABASE_USERNAME") - line.gsub!(/ENTER_USER_DATABASE_USERNAME/, config[:web_apollo_admin]) - elsif line.include?("ENTER_USER_DATABASE_PASSWORD") - line.gsub!(/ENTER_USER_DATABASE_PASSWORD/, config[:web_apollo_admin_pw]) - elsif line.include?("ENTER_PATH_TO_REFSEQS_JSON_FILE") - line.gsub!(/ENTER_PATH_TO_REFSEQS_JSON_FILE/, "#{config[:data_dir]}/refSeqs.json") - elsif line.include?("ENTER_ORGANISM") - line.gsub!(/ENTER_ORGANISM/ , config[:organism] ) - elsif line.include?("/config/translation_tables") - line.gsub!(/ncbi_1_/, "ncbi_#{config[:translation_table]}_") - end - - parsed_content << line - end - f.close - - parsed_content.compact! - - o = File.new(file, "w+") - o.puts parsed_content.join("\n") - o.close - -end - -def parse_hibernate_xml(file,config) - - parsed_content = [] - f = File.open(file,"r") - while (line = f.gets) - if line.include?("ENTER_DATABASE_CONNECTION_URL") - line.gsub!(/ENTER_DATABASE_CONNECTION_URL/, "jdbc:postgresql://localhost/#{config[:chado_db]}") - elsif line.include?("ENTER_USERNAME") - line.gsub!(/ENTER_USERNAME/, "#{config[:chado_db_user]}") - elsif line.include?("ENTER_PASSWORD") - line.gsub!(/ENTER_PASSWORD/, "#{config[:chado_db_user_pw]}") - end - - parsed_content << line - - end - f.close - parsed_content.compact! - - o = File.new(file, "w+") - o.puts parsed_content.join("\n") - o.close - -end - -def parse_blat_xml(file,config) - - - lines = IO.readlines(file) - parsed_lines = [] - - lines.each do |line| - if line.include?("ENTER_PATH_TO_BLAT_BINARY") - line.gsub!(/ENTER_PATH_TO_BLAT_BINARY/, "#{config[:tool_dir]}/blat") - elsif line.include?("ENTER_PATH_FOR_TEMPORARY_DATA") - line.gsub!(/ENTER_PATH_FOR_TEMPORARY_DATA/, '/tmp') - elsif line.include?("ENTER_PATH_TO_BLAT_DATABASE") - line.gsub!(/ENTER_PATH_TO_BLAT_DATABASE/, "#{config[:annotation_dir]}/blat.2bit") - elsif line.include?("ENTER_ANY_BLAT_OPTIONS") - line.gsub!(/ENTER_ANY_BLAT_OPTIONS/, '-minScore=100 -minIdentity=60') - end - - parsed_lines << line.strip - - end - - f = File.new(file,"w+") - f.puts parsed_lines.join("\n") - f.close - -end - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -options.clean = false -opts.on("-s","--species", "=SPECIES","Species name") {|argument| options.species = argument } -opts.on("-g","--gff", "=GFF","Annotation") {|argument| options.gff = argument } -opts.on("-f","--fasta", "=FASTA","Fasta file") {|argument| options.fasta = argument } -opts.on("-c","--[no]clean","Clean up project") { options.clean = true } -opts.on("-t","--translation_table","=TRANSLATION_TABLE","NCBI translation table to use") { |argument| options.translation_table = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -raise "You are not member of the tomcat group and thus cannot deploy WebApollo!" unless tomcat_group - -@species = options.species or abort 'No species name provided' -@organism = options.species.split('_')[0].capitalize + ' ' + options.species.split('_')[-1] -@fasta = options.fasta or abort 'No genome sequence provided' -options.translation_table ? @translation_table = options.translation_table : @translation_table = "1" - -# Custom CSS styles needed for WA -CSS_STRING = ".plus-cigarM {\nbackground-color: green; /* color for plus matches */\n}\n\n.minus-cigarM {\nbackground-color: blue; /* color for minus matches */\n}\n" - -### Usernames, passwords and locations - -user = ENV['USER'] -home = ENV['HOME'] -user_db_admin = ENV['WA_USER_DB_ADMIN'] or abort "Environment variable WA_PGUSER not set" -user_db_admin_pw = ENV['WA_WA_USER_DB_ADMIN_PW'] or abort "Environment variable WA_PGPASS not set" -wa_website_username = ENV['WA_WEBSITE_USERNAME'] or abort "Environment variable WA_WEBSITE_USERNAME not set" -wa_website_password = ENV['WA_WEBSITE_PASSWORD'] or abort "Environment variable WA_WEBSITE_PASSWORD not set" - -build_dir = ENV['APOLLO_BUILD_DIR'] or abort "Environment variable APOLLO_BUILD_DIR not set" -data_dir = ENV['APOLLO_DATA_DIR'] or abort "Environment vairable APOLLO_DATA_DIR not set" - -web_apollo_storage = "#{data_dir}/#{@species}" # Folder tree where data is stored -tomcat_apps = "/var/lib/tomcat/webapps" # Deployment location - -config = { - - :pguser => "#{user_db_admin}", # Username of the SQL WA admin - :pgpass => "#{user_db_admin_pw}", # PW of the SQL WA admin - :web_apollo_admin => "#{wa_website_username}", # Username of admin for WA website - :web_apollo_admin_pw => "#{wa_website_password}", # Password of WA website admin - :web_apollo_user_db => "web_apollo_users_#{@species}", # Name of the user database for this WA project - :web_apollo_source => "#{build_dir}/template_march2015", # The pre-built template install - :web_apollo_build => "#{build_dir}/#{@species}", # The location where this WA project is to be build - :web_apollo_storage => "#{web_apollo_storage}", # Location where data is stored - :annotation_dir => "#{web_apollo_storage}/annotations", # Where annotation data is stored - :translation_table => @translation_table, # NCBI translation table to use - :data_dir => "#{web_apollo_storage}/data", # Where the Jbrowse data is stored - :tool_dir => "/opt/ucsc", # Location of blat and FaToNib - :organism => @organism, # Species name - :chado_db => "nbis_chado", # Name of the chado db to use for storing annotations (optional) - :chado_db_user => "nbis_chado_user", # User with write permissions in chado db - :chado_db_user_pw => "nbis_chado_user" # PW for chado user -} - -### File targets - -config_files = [ "sample_config.properties" , "sample_config.xml" , "sample_blat_config.xml", "sample_hibernate.xml" ] - -### The workflow - -if options.clean == true - system("rm -Rf #{config[:web_apollo_storage]}") - system("rm -Rf #{config[:web_apollo_build]}") - system("rm -R temp") - system("psql -d template1 -U #{config[:pguser]} -c \"DROP DATABASE IF EXISTS #{config[:web_apollo_user_db]}\"") - -else - File.directory?(config[:web_apollo_source]) or raise "No template installation found!" - - # Create the folder where the data is to be stored - system("mkdir -p #{config[:web_apollo_storage]}") - system("mkdir -p #{config[:annotation_dir]}") - system("mkdir -p #{config[:data_dir]}") - system("chgrp -R tomcat #{config[:web_apollo_storage]}") # Must be owned by tomcat group - system("mkdir -p #{config[:web_apollo_build]}") - # Create a temporary folder - system("mkdir -p temp") - # Create a copy of the webapollo template code for this installation - system("mkdir -p #{config[:web_apollo_build]}") - system("cp -R #{config[:web_apollo_source]}/* #{config[:web_apollo_build]}") - - # Create a new database for this genome - system("psql -d template1 -U #{config[:pguser]} -c \"DROP DATABASE IF EXISTS #{config[:web_apollo_user_db]}\"") - system("psql -d template1 -U #{config[:pguser]} -c \"CREATE DATABASE #{config[:web_apollo_user_db]}\"") - # Load the database schema - system("psql -d #{config[:web_apollo_user_db]} -U #{config[:pguser]} -f #{config[:web_apollo_source]}/tools/user/user_database_postgresql.sql") - # Add website admin user - system("#{config[:web_apollo_build]}/tools/user/add_user.pl -D #{config[:web_apollo_user_db]} -U #{config[:pguser]} -P #{config[:pgpass]} -u #{config[:web_apollo_admin]} -p #{config[:web_apollo_admin_pw]}") - # Load genome assembly - system("#{config[:web_apollo_build]}/tools/user/extract_seqids_from_fasta.pl -p Annotations- -i #{@fasta} -o temp/seqids.txt") - system("#{config[:web_apollo_build]}/tools/user/add_tracks.pl -D #{config[:web_apollo_user_db]} -U #{config[:pguser]} -P #{config[:pgpass]} -t temp/seqids.txt") - system("#{config[:web_apollo_build]}/tools/user/set_track_permissions.pl -D #{config[:web_apollo_user_db]} -U #{config[:pguser]} -P #{config[:pgpass]} -u #{config[:web_apollo_admin]} -t temp/seqids.txt -a") - system("#{config[:web_apollo_build]}/bin/prepare-refseqs.pl --fasta #{@fasta} --out #{config[:data_dir]}") - # LOADING ANNOTATIONS ? - - # Add webapollo plugin to the genome browser - system("#{config[:web_apollo_build]}/client/apollo/bin/add-webapollo-plugin.pl -i #{config[:data_dir]}/trackList.json") - - # Update the config files - system("echo jbrowse.data=#{config[:data_dir]} > #{config[:web_apollo_build]}/config.properties") - system("echo datastore.directory=#{config[:annotation_dir]} >> #{config[:web_apollo_build]}/config.properties") - system("echo database.url=jdbc:postgresql://localhost/#{config[:web_apollo_user_db]} >> #{config[:web_apollo_build]}/config.properties") - system("echo database.username=#{config[:pguser]} >> #{config[:web_apollo_build]}/config.properties") - system("echo database.password=#{config[:pgpass]} >> #{config[:web_apollo_build]}/config.properties") - system("echo organism=#{@organism} >> #{config[:web_apollo_build]}/config.properties") - system("echo tracks.refseqs=#{config[:data_dir]}/seq/refSeqs.json >> #{config[:web_apollo_build]}/config.properties ") - system("echo tracks.data=#{config[:data_dir]} >> #{config[:web_apollo_build]}/config.properties") - - parse_config_xml("#{config[:web_apollo_build]}/config.xml",config) - parse_hibernate_xml("#{config[:web_apollo_build]}/hibernate.xml",config) - parse_blat_xml("#{config[:web_apollo_build]}/blat_config.xml",config) - - # Create custom CSS style sheet - f = File.new("#{config[:data_dir]}/custom.css","w") - f.puts CSS_STRING - f.close - - # Build Blat database - system("#{config[:tool_dir]}/faToTwoBit #{@fasta} #{config[:annotation_dir]}/blat.2bit") - - # Build the webapollo war file - Dir.chdir(config[:web_apollo_build]) do - system("./apollo deploy") - end - - # Copy the packaged WebApollo installation to the Tomcat folder - system("cp #{config[:web_apollo_build]}/target/apollo*.war #{tomcat_apps}/#{@species}.war") - -end - diff --git a/annotation/tools/webapollo/apollo1/gaas_setup_rakefile.rb b/annotation/tools/webapollo/apollo1/gaas_setup_rakefile.rb deleted file mode 100755 index 75c098acb..000000000 --- a/annotation/tools/webapollo/apollo1/gaas_setup_rakefile.rb +++ /dev/null @@ -1,348 +0,0 @@ -#!/usr/bin/ruby - -require 'fileutils' - -# A rake file to set up a new WebApollo instance -GENOME = ENV['genome'].downcase -abort "Must provide a genome name or horrible things will happen" unless GENOME -SEQUENCE = ENV['sequence'] -abort "Must provide a genome sequence!" unless SEQUENCE -ANNOTATION = ENV['gff'] -abort "Must provide an annotation!" unless ANNOTATION - -WEB_APOLLO_INSTALL_DIR = ENV['install_dir'] || "/databases/webapollo/WebApollo-2014-04-03" # the directory with the installation files -WEB_APOLLO_DIR = "/usr/share/tomcat7/webapps/#{GENOME}" - - -# Determine where all the data will live (BAM files, annotations etc) -STORAGE_DIR = "/databases/data" - -BLAT_DIR = "/databases/tools/blat" - -WORK_DIR=Dir.getwd - -# Some key variables: - -# -- The user with admin rights to the user DB -user_db = "web_apollo_users_#{GENOME}" -user_db_admin = ENV['WA_USER_DB_ADMIN'] or abort "Environment variable WA_PGUSER not set" -user_db_admin_pw = ENV['WA_WA_USER_DB_ADMIN_PW'] or abort "Environment variable WA_PGPASS not set" - -# -- The user with admin rights on the website <= Default value during installation process -web_apollo_admin = "web_apollo_admin" -web_apollo_admin_pw = "web_apollo_admin" - -# -- The Chado DB stores modified annotations -chado_db = "nbis_chado" -chado_db_user = "chado_admin" -chado_db_user_pw = "chado_admin" - -# -- Custom CSS styles we wish to include (e.g. stranded RNAseq data etc) -CSS_STRING = ".plus-cigarM {\nbackground-color: green; /* color for plus matches */\n}\n\n.minus-cigarM {\nbackground-color: blue; /* color for minus matches */\n}\n" - -############################################### -#### HERE BE DRAGONS! ######################### -####=Things you don't want to mess with######## -############################################### - -directory 'log' -directory 'scratch' -directory 'split_gff' - -# rake targets (files that need to be generated) -# Only way to create targets for PSQL is to -# write log files. -user_db_create_log = "log/user_db_create.log" -user_db_populate_log = "log/user_db_populate.log" -user_db_add_web_user_log = "log/user_db_add_web_user.log" -user_db_add_sequence_id_log = "log/user_db_add_sequence_id.log" - -extract_sequence_id = "scratch/#{SEQUENCE}.ids.txt" -## - -desc 'Create the user database for this annotation project' -namespace :userdb do - - file user_db_create_log => 'log' do |f| - system("psql -d template1 -U #{user_db_admin} -c \"DROP DATABASE IF EXISTS #{user_db}\"") - system("psql -L #{f} -d template1 -U #{user_db_admin} -c \"CREATE DATABASE #{user_db}\"") - end - - file user_db_populate_log => user_db_create_log do |f| - system("psql -L #{f} -d #{user_db} -U #{user_db_admin} -f #{WEB_APOLLO_INSTALL_DIR}/tools/user/user_database_postgresql.sql") - end - - file user_db_add_web_user_log => user_db_populate_log do |f| - system("perl #{WEB_APOLLO_INSTALL_DIR}/tools/user/add_user.pl -D #{user_db} -U #{user_db_admin} -P #{user_db_admin_pw} -u #{web_apollo_admin} -p #{web_apollo_admin_pw} 2> #{f}") - end - - file extract_sequence_id => [ 'scratch', user_db_add_web_user_log] do |f| - system("perl #{WEB_APOLLO_INSTALL_DIR}/tools/user/extract_seqids_from_fasta.pl -p Annotations- -i #{SEQUENCE} -o #{f}") - end - - file user_db_add_sequence_id_log => extract_sequence_id do |f| - system("perl #{WEB_APOLLO_INSTALL_DIR}/tools/user/add_tracks.pl -D #{user_db} -U #{user_db_admin} -P #{user_db_admin_pw} -t #{extract_sequence_id} 2> #{f}") - system("perl #{WEB_APOLLO_INSTALL_DIR}/tools/user/set_track_permissions.pl -D #{user_db} -U #{user_db_admin} -P #{user_db_admin_pw} -u #{web_apollo_admin} -t #{extract_sequence_id} -a") - end - - task :create => user_db_add_sequence_id_log - -end - -desc 'Create the Tomcat folder' - -namespace :servlet do - - - task :make_folder => "userdb:create" do - system("mkdir -p #{WEB_APOLLO_DIR}") - FileUtils.cd("#{WEB_APOLLO_DIR}") { - system("jar -xvf #{WEB_APOLLO_INSTALL_DIR}/war/WebApollo.war 2> /dev/null ") - } - end - - task :create => :make_folder - -end - -## -config_copy = "scratch/config.xml" -hibernate_copy = "scratch/hibernate.xml" -## - -namespace :config do - - file config_copy => 'servlet:create' do |f| - parsed_content = [] - fil = File.open("#{WEB_APOLLO_DIR}/config/config.xml","r") - while (line = fil.gets) - - if line.include?("ENTER_DATASTORE_DIRECTORY_HERE") - line.gsub!(/ENTER_DATASTORE_DIRECTORY_HERE/, "#{STORAGE_DIR}/#{GENOME}/") - elsif line.include?("ENTER_USER_DATABASE_JDBC_URL") - line.gsub!(/ENTER_USER_DATABASE_JDBC_URL/, "jdbc:postgresql://localhost/web_apollo_users_#{GENOME}") - elsif line.include?("ENTER_USER_DATABASE_USERNAME") - line.gsub!(/ENTER_USER_DATABASE_USERNAME/, "#{user_db_admin}") - elsif line.include?("ENTER_USER_DATABASE_PASSWORD") - line.gsub!(/ENTER_USER_DATABASE_PASSWORD/, "#{user_db_admin_pw}") - elsif line.include?("ENTER_PATH_TO_REFSEQS_JSON_FILE") - line.gsub!(/ENTER_PATH_TO_REFSEQS_JSON_FILE/, "#{WEB_APOLLO_DIR}/jbrowse/data/seq/refSeqs.json") - elsif line.include?("ENTER_ORGANISM") - line.gsub!(/ENTER_ORGANISM/ , "#{GENOME.capitalize.split('_').join(' ')}") - elsif line.include?("ENTER_CVTERM_FOR_SEQUENCE") - line.gsub!(/ENTER_CVTERM_FOR_SEQUENCE/, 'sequence:contig') - end - - parsed_content << line - end - fil.close - - parsed_content.compact! - - o = File.new("#{f}", "w+") - o.puts parsed_content.join("\n") - o.close - - system("cp #{f} #{WEB_APOLLO_DIR}/config/config.xml") - - end - - file hibernate_copy => config_copy do |f| - - parsed_content = [] - fil = File.open("#{WEB_APOLLO_DIR}/config/hibernate.xml","r") - while (line = fil.gets) - if line.include?("ENTER_DATABASE_CONNECTION_URL") - line.gsub!(/ENTER_DATABASE_CONNECTION_URL/, "jdbc:postgresql://localhost/#{chado_db}") - elsif line.include?("ENTER_USERNAME") - line.gsub!(/ENTER_USERNAME/, "#{chado_db_user}") - elsif line.include?("ENTER_PASSWORD") - line.gsub!(/ENTER_PASSWORD/, "#{chado_db_user_pw}") - end - - parsed_content << line - - end - fil.close - parsed_content.compact! - - o = File.new("#{f}", "w+") - o.puts parsed_content.join("\n") - o.close - - system("cp #{f} #{WEB_APOLLO_DIR}/config/hibernate.xml") - end - - task :parse => hibernate_copy - -end - -namespace :blat do - - blat_db = "#{STORAGE_DIR}/#{GENOME}/blat.2bit" - blat_config = "#{WEB_APOLLO_DIR}/config/blat_config.xml" - blat_config_copy = "#{WORK_DIR}/scratch/blat_config.xml" - - file blat_db => 'config:parse' do - system("mkdir -p #{STORAGE_DIR}/#{GENOME}") - FileUtils.cd("#{STORAGE_DIR}/#{GENOME}") { - system("#{BLAT_DIR}/faToTwoBit #{WORK_DIR}/#{SEQUENCE} #{blat_db}") - } - end - - file blat_config_copy => blat_db do |f| - - lines = IO.readlines(blat_config) - parsed_lines = [] - - file = File.new("#{WORK_DIR}/scratch/blat_config.xml","w+") - - - lines.each do |line| - if line.include?("ENTER_PATH_TO_BLAT_BINARY") - line.gsub!(/ENTER_PATH_TO_BLAT_BINARY/, "#{BLAT_DIR}/blat") - elsif line.include?("ENTER_PATH_FOR_TEMPORARY_DATA") - line.gsub!(/ENTER_PATH_FOR_TEMPORARY_DATA/, '/tmp') - elsif line.include?("ENTER_PATH_TO_BLAT_DATABASE") - line.gsub!(/ENTER_PATH_TO_BLAT_DATABASE/, "#{blat_db}") - elsif line.include?("ENTER_ANY_BLAT_OPTIONS") - line.gsub!(/ENTER_ANY_BLAT_OPTIONS/, '-minScore=100 -minIdentity=60') - end - - parsed_lines << line.strip - - end - - file.puts parsed_lines.join("\n") - - file.close - - system("cp #{f} #{blat_config}") - - end - - task :create_config => blat_config_copy - -end - -namespace :data do - - - task :data_dir => 'blat:create_config' do - system("mkdir -p #{STORAGE_DIR}/#{GENOME}") - end - - task :dna_track_setup => :data_dir do - system("perl #{WEB_APOLLO_DIR}/jbrowse/bin/prepare-refseqs.pl --fasta #{WORK_DIR}/#{SEQUENCE}") - end - - task :link_data_dir => :dna_track_setup do - system("ln -sf #{STORAGE_DIR}/#{GENOME} #{WEB_APOLLO_DIR}/jbrowse/data") - end - - task :copy_json => :link_data_dir do - system("cp -R #{WORK_DIR}/data/* #{STORAGE_DIR}/#{GENOME}") - end - - task :add_plugin => :copy_json do - system("chmod +x #{WEB_APOLLO_DIR}/jbrowse/bin/*.pl") - system("#{WEB_APOLLO_DIR}/jbrowse/bin/add-webapollo-plugin.pl -i #{WEB_APOLLO_DIR}/jbrowse/data/trackList.json") - end - - task :split_gff_file => ['split_gff', :add_plugin ] do - system("perl #{WEB_APOLLO_INSTALL_DIR}/tools/data/split_gff_by_source.pl -i #{ANNOTATION} -d split_gff") - end - -end - -namespace :gff do - - - task :parse => "data:split_gff_file" do - - files = Dir["split_gff/*.gff"] - - warn files.inspect - - maker = files.find{|f| f.include?("maker") } || nil - protein = files.find{|f| f.include?("protein_coding") } || nil - - system("chmod +x #{WEB_APOLLO_DIR}/jbrowse/bin/flatfile-to-json.pl") - - FileUtils.cd("#{WEB_APOLLO_DIR}/jbrowse") { - - - if maker - files.delete_if{|f| f.include?("maker") } - system("bin/flatfile-to-json.pl --gff #{WORK_DIR}/split_gff/maker.gff --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{\"wholeCDS\": null, \"CDS\":\"brightgreen-80pct\", \"UTR\": \"darkgreen-60pct\", \"exon\":\"container-100pct\"}' --cssClass container-16px --type mRNA --trackLabel maker") - elsif protein - files.delete_if{|f| f.include?("protein_codin") } - system("bin/flatfile-to-json.pl --gff #{WORK_DIR}/split_gff/protein_coding.gff --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{\"wholeCDS\": null, \"CDS\":\"brightgreen-80pct\", \"UTR\": \"darkgreen-60pct\", \"exon\":\"container-100pct\"}' --cssClass container-16px --type mRNA --trackLabel EnsEMBLProtein") - - end - - files.each do |gff_file| - feature = gff_file.split("/")[-1].split(".")[0] - system("bin/flatfile-to-json.pl --gff #{WORK_DIR}/#{gff_file} --arrowheadClass webapollo-arrowhead --getSubfeatures --subfeatureClasses '{\"match_part\": \"darkblue-80pct\"}' --cssClass container-10px --trackLabel #{feature}") - end - } - end - - task :add_names => :parse do - - FileUtils.cd("#{WEB_APOLLO_DIR}/jbrowse") { - system("bin/generate-names.pl") - } - end - -end - -css_file = "#{WEB_APOLLO_DIR}/jbrowse/data/custom.css" -json_file = "#{WEB_APOLLO_DIR}/jbrowse/data/trackList.json" -json_file_copy = "#{STORAGE_DIR}/#{GENOME}/trackList.json.copy" - -desc 'Creates the custom CSS file' -namespace :css do - - file css_file => 'gff:parse' do |f| - file = File.new(css_file,"w+") - file.puts CSS_STRING - file.close - end - - file json_file_copy => css_file do - - file = File.open(json_file,"r") - lines = IO.readlines(json_file) - lines[0] = "\"css\" : \"data/custom.css\",\n" - lines.unshift("{\n") - file.close - - copy = File.new(json_file_copy,"w+") - copy.puts lines.join - copy.close - - system("cp #{json_file_copy} #{json_file}") - end - - task :generate_custom_css => json_file_copy -end - - - -task :default => 'css:generate_custom_css' - -task :clean do - - system("rm -fR #{WEB_APOLLO_DIR}") - system("rm -fR #{WORK_DIR}/data") - system("rm -R log") - system("rm -Rf #{STORAGE_DIR}/#{GENOME}") - system("rm -R split_gff") - system("rm -R scratch") - system("psql -d template1 -U #{user_db_admin} -c \"DROP DATABASE IF EXISTS #{user_db}\"") - -end - - - diff --git a/annotation/tools/webapollo/apollo1/gaas_sync_user_db.rb b/annotation/tools/webapollo/apollo1/gaas_sync_user_db.rb deleted file mode 100755 index aeb18ef3b..000000000 --- a/annotation/tools/webapollo/apollo1/gaas_sync_user_db.rb +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# sync_user_db.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# Parses a WebApollo SQL file and updates the local user database -# -# == OPTIONS -# -h,--help:: Show help -# -i,--infile=INFILE:: input file -# -o,--outfile=OUTFILE:: output file - -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -opts.on("-i","--infile", "=INFILE","Input") {|argument| options.infile = argument } -opts.on("-s","--species", "=SPECIES","Species to use") {|argument| options.species = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -abort "Must provide species name!" unless options.species -abort "Must provide an input file!" unless options.infile - -home = ENV['HOME'] - -WEB_APOLLO_SCRIPT="/big/webapollo/build/#{options.species}/tools/user/add_user.pl" -# "#{home}/webapollo/build/template/tools/user/add_user.pl" - -options.infile ? input_stream = File.open(options.infile) : input_stream = $stdin - -while (line = input_stream.gets) - - next unless line.match(/^[0-9]/) - - user_id,name,pass = line.strip.split("\t") - - next if user_id == "1" - - warn "Adding user #{name} with password #{pass} to database web_apollo_users_#{options.species}" - - system("perl #{WEB_APOLLO_SCRIPT} -D web_apollo_users_#{options.species} -U web_apollo_users_admin -P web_apollo_users_admin -u #{name} -p #{pass}") - -end - - - diff --git a/annotation/tools/webapollo/apollo1/gaas_transplant.rb b/annotation/tools/webapollo/apollo1/gaas_transplant.rb deleted file mode 100755 index 86ff87fec..000000000 --- a/annotation/tools/webapollo/apollo1/gaas_transplant.rb +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# transplant.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# Transplants a WebApollo installation -# -# == OPTIONS -# -h,--help:: Show help -# -i,--infile=INFILE:: input file -# -o,--outfile=OUTFILE:: output file - -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -opts.on("-s","--species", "=SPECIES","Name of species to transplant") {|argument| options.species = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -home = ENV['HOME'] - -SERVER = "nbis-web.imbim.uu.se" -USER = "root" -LOCAL_PROJECT = "/big/webapollo/projects/#{options.species}" -LOCAL_DATA = "/big/data/#{options.species}" -TRANSFER = "/big/transfer/#{options.species}" -REMOTE_PROJECT = "/databases/webapollo/#{options.species}" -REMOTE_DATA = "/databases/data/#{options.species}" - -# Create local folders -system("mkdir -p #{TRANSFER}") -system("mkdir -p #{LOCAL_PROJECT}") - -# Copy remote folders/files -# Genome sequence -system("scp #{USER}@#{SERVER}:#{REMOTE_PROJECT}/genome.fa #{LOCAL_PROJECT}/") -abort "No genome sequence has been transferred from remote host (expecting: genome.fa)" unless File.exists?("#{LOCAL_PROJECT}/genome.fa") - -# User db, if dumped -system("scp #{USER}@#{SERVER}:#{REMOTE_PROJECT}/userdb.sql #{LOCAL_PROJECT}/") - -# Data -system("scp -r #{USER}@#{SERVER}:#{REMOTE_DATA}/* #{TRANSFER}") - -# Deploy local installation -system("ruby #{home}/git/code/WebApollo/new_species.rb -s #{options.species} -f #{LOCAL_PROJECT}/genome.fa") - -# Copy the old data to new location -system("cp -R #{TRANSFER}/Annotations* #{LOCAL_DATA}/annotations/") -system("cp -R #{TRANSFER}/track* #{LOCAL_DATA}/data/") -system("cp -R #{TRANSFER}/blat* #{LOCAL_DATA}/annotations/") -system("cp -R #{TRANSFER}/bam #{LOCAL_DATA}/data/") - -system("chown -R #{ENV['USER']}:tomcat #{LOCAL_DATA}") diff --git a/annotation/tools/webapollo/apollo2/gaas_apollo_track_helper.rb b/annotation/tools/webapollo/apollo2/gaas_apollo_track_helper.rb deleted file mode 100755 index d62886f9c..000000000 --- a/annotation/tools/webapollo/apollo2/gaas_apollo_track_helper.rb +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# apollo_track_helper.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -g | --gff ] |[ -s | --species ] | -# == DESCRIPTION -# A script to manage tracks for a WebApollo installation -# -# == OPTIONS -# -h,--help:: Show help -# -s,--species=SPECIES:: Name of the species -# -g,--gff=GFF:: Annotation file to process (optional) -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -opts.on("-i","--infile", "=INFILE","Input") {|argument| options.infile = argument } -opts.on("-r","--remove", "Remove track, requires species (-s) and label (-l)") {|argument| options.remove = true } -opts.on("-s","--species", "=SPECIES","Name of the species") {|argument| options.species = argument } -opts.on("-c","--category", "=CATEGORY","Track category") {|argument| options.category = argument } -opts.on("-l","--label", "=LABEL","Label") {|argument| options.label = argument } -opts.on("-o","--outfile", "=OUTFILE","Output") {|argument| options.outfile = argument } -opts.on("-w","--wa_installation", "=wa_installation_name","path to the WA installation") {|argument| options.wa_installation_name = argument } -opts.on("-d","--direct", "=DIRECT","Direct") {|argument| options.direct = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -### Usernames, passwords and locations - -home = ENV['HOME'] - -build_dir = ENV['APOLLO_BUILD_DIR'] or abort "Environment variable APOLLO_BUILD_DIR not set" -data_dir = ENV['APOLLO_DATA_DIR'] or abort "Environment vairable APOLLO_DATA_DIR not set" - -config = { - :web_apollo_build => "#{build_dir}/#{options.wa_installation_name}", # The location where this WA isntance is - :web_apollo_data => "#{data_dir}/#{options.species}" # Location of the data store for this species -} - -### The workflow - -tracks = { "protein" => "\"match_part\": \"blue-80pct\"" , - "est" => "\"match_part\": \"green-80pct\"" , - "repeat" => "\"match_part\": \"green-80pct\"" , - "tRNA" => "\"exon\": \"green-80pct\"", - "ncRNA" => "\"exon\": \"green-80pct\"", - "synteny" => "\"nucleotide_motif\": \"springgreen-80pct\"", - "rnaseq_match" => "\"match_part\": \"orange-80pct\"" , - "rnaseq" => "\"exon\" : \"green-80pct\"", - "abinito" => "\"match_part\": \"springgreen-80pct\"", - "gene" => "\"wholeCDS\": null, \"CDS\": \"blueviolet-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"", - "lift-over" => "\"wholeCDS\": null, \"CDS\": \"green-80pct\", \"UTR\": \"darkorange-60pct\", \"exon\" : \"container-100pct\"" - } - - -abort "No species provided" unless options.species -raise "This WA instance/installation (#{options.wa_installation_name}) does not have a build directory under #{config[:web_apollo_build]})" unless File.directory?(config[:web_apollo_build]) -raise "This species (#{options.species}) does not have a build directory under #{config[:web_apollo_data]})" unless File.directory?(config[:web_apollo_data]) -abort "No track label provided" unless options.label - -if options.remove - - system("perl #{config[:web_apollo_build]}/bin/remove-track.pl --dir #{config[:web_apollo_data]} --trackLabel #{options.label} -D") - -else - - abort "No track provided" if options.infile.nil? - abort "Must provide a category for this track" unless options.category - abort "A track with the label (#{options.label}) already exits for the species (#{options.species})." if File.directory?("#{config[:web_apollo_data]}/tracks/#{options.label}") - - ## Some useful variables - - track = nil - track_number = {} - proceed = false - failure = 0 - - ## - - # List the current information - puts "Your data:" - puts "----------" - puts "Track to load: #{options.infile}" - puts "WebApollo portal: #{config[:web_apollo_build]}" - puts "Track label: #{options.label}" - puts "Category: #{options.category}" - puts "Track type selection..." - puts - - # Ask about the type of data - - - while proceed == false - - abort "Can't make up your mind, eh? Aborting..." if failure > 3 - - puts "###############################################" - puts "Choose the track type from the following list:" - - number = 0 - - tracks.sort_by{|t,f| t}.each do |track_type,formatting| - number += 1 - track_number[number] = track_type - track = track_type - puts "\t#{number}\t#{track_type}" - end - - puts "##############################################" - - - if options.direct - selection = options.direct - proceed = true - track = track_number[selection.to_i] - else - puts "Enter the number corresponding to your choice:" - selection = gets.chomp - - next unless track_number.has_key?(selection.to_i) - - puts "You selected: #{track_number[selection.to_i]} - is that correct? (Y/N)" - - answer = gets.chomp - - if answer.downcase == "y" - proceed = true - track = track_number[selection.to_i] - else - failure += 1 - end - end - - end - - puts "Loading track as type #{track}, with the label #{options.label} into the category #{options.category} of webapollo directory #{config[:web_apollo_build]}" - -unless options.direct - puts "Proceed? (Y/N)" - - answer = gets.chomp - - abort "Aborting..." unless answer.downcase == "y" -end - - if track == "gene" or track == "lift-over" or track == "rnaseq" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type mRNA --trackLabel #{options.label}" - elsif track == "tRNA" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type tRNA --trackLabel #{options.label}" - elsif track == "ncRNA" - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --type ncRNA --trackLabel #{options.label}" - else - system "perl #{config[:web_apollo_build]}/bin/flatfile-to-json.pl --gff #{options.infile} --out #{config[:web_apollo_data]} --arrowheadClass trellis-arrowhead --getSubfeatures --subfeatureClasses '{#{tracks[track]}}' --cssClass container-16px --config '{ \"category\": \"#{options.category}\" }' --trackLabel #{options.label}" - end - -end diff --git a/annotation/tools/webapollo/apollo2/gaas_install_WA_2_0_X.rb b/annotation/tools/webapollo/apollo2/gaas_install_WA_2_0_X.rb deleted file mode 100755 index 980199d7e..000000000 --- a/annotation/tools/webapollo/apollo2/gaas_install_WA_2_0_X.rb +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# build.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# A script to build a new WebApollo installation (version 2.0 and up) -# You only need to do this once - Managing species will then be done directly from web interface -# -# == OPTIONS -# -h,--help:: Show help -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Jacques Dainat, jacques.dainat@nbis.se - -require 'optparse' -require 'ostruct' - -#################################### -### Define modules and classes here - -def tomcat_group - - user_groups = `id` - user_groups.include?("tomcat") - -end - -def parse_apollo_config(file,config) - parsed_content = [] - f = File.open(file,"r") - while (line = f.gets) - if line.include?("url =") - line.gsub!(/"jdbc:postgresql:\/\/localhost\/apollo.*"/, "\"jdbc:postgresql://localhost/#{config[:web_apollo_db]}\"") - elsif line.include?("username =") - line.gsub!(//, "#{config[:pguser]}") - elsif line.include?("password =") - line.gsub!(//, "#{config[:pgpass]}") - end - - parsed_content << line - - end - f.close - parsed_content.compact! - - o = File.new(file, "w+") - o.puts parsed_content - o.close - -end - -#################################################### -### Get the script arguments and open relevant files - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -options.clean = false -opts.on("-n","--name", "=NAME","name of the installation") {|argument| options.name = argument } -opts.on("-c","--[no]clean","Clean up the installation") { options.clean = true } -opts.on("-t","--table","=INTEGER","Codon table used. By default it is the table 1") { |argument| options.codonTable = Integer(argument) } -opts.on("-p","--path","=PATH","Define the path to the WA folder to be installed. By default we are looking at: /big/webapollo/release/live_WA_2") { |argument| options.path = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -raise "You are not member of the tomcat group and thus cannot deploy WebApollo!" unless tomcat_group - -@name = options.name or abort 'No Webapollo installation name provided' - -################### -### Usernames, passwords and locations - -user = ENV['USER'] -home = ENV['HOME'] -build_dir = ENV['APOLLO_BUILD_DIR'] or abort "Environment variable APOLLO_BUILD_DIR not set" -user_db_admin = ENV['WA_DB_ADMIN'] or abort "Environment variable WA_PGUSER not set" -user_db_admin_pw = ENV['WA_DB_ADMIN_PW'] or abort "Environment variable WA_PGPASS not set" -tomcat_apps = "/var/lib/tomcat/webapps" # Deployment location - - - -#Define the codon table to use -unless defined?(options.codonTable).nil? # If define we give the default path - if (options.codonTable<1 || options.codonTable>25) - puts "The --table option expects an integer between 1 and 25" - exit - end - if (options.codonTable>1) #We have to add the information to the otpion file - @addCodonString=options.codonTable - end -end - -#Define path to the WA folder -if (defined?(options.path)).nil? # If not define we give the default path - path="/big/webapollo/release/live_WA_2" -else - path=options.path -end - -config = { - :web_apollo_source => "#{path}",# The source code of webapollo - :web_apollo_build => "#{build_dir}/#{@name}", # The location where this WA project is to be build - - :web_apollo_db => "web_apollo_#{@name}", # Name of the user database for this WA project - :pgpass => "#{user_db_admin_pw}", # PW of the SQL WA admin - :pguser => "#{user_db_admin}" # Username of the SQL WA admin -} - - -### The workflow -if options.clean == true - - puts "Are you really sure to erase the whole webapollo installation ( #{tomcat_apps}/#{@name}, #{config[:web_apollo_build]},DB:#{config[:web_apollo_db]} ) ? [y|n]:" - selection = gets.chomp - if(selection.downcase == "y") - puts "Lets remove everything" - - puts "Cleaning webapollo folder" - system("sudo rm -Rf #{config[:web_apollo_build]}") - puts "Cleaning database" -# system("psql -d template1 -U #{config[:pguser]} -c \"DROP DATABASE IF EXISTS #{config[:web_apollo_db]}\"") - system("sudo su - postgres -c \"dropdb #{config[:web_apollo_db]}\"") - puts "Cleaning tomcat folder" - system("rm -f #{tomcat_apps}/#{@name}.war") - system("sudo rm -Rf #{tomcat_apps}/#{@name}") - puts "Cleaning finished" - else - puts "Fine we let everything as it was." - end -else - - File.directory?(config[:web_apollo_source]) or abort "Could not find the reference folder (expected: #{config[:web_apollo_source]})" - abort "Installation already exist. Use flag '--clean' to remove!" if File.directory?(config[:web_apollo_build]) - - # Create the folder where the data is to be stored - puts "Create folders" - system("mkdir -p #{config[:web_apollo_build]}") - - # Create a copy of the webapollo code for this installation - puts "Create a copy of the webapollo source" - system("cp -R #{config[:web_apollo_source]}/* #{config[:web_apollo_build]}") - - # Copy the template config files into place and configurate it - puts "rename the config file and configure it properly" - system("cp #{config[:web_apollo_build]}/sample-postgres-apollo-config.groovy #{config[:web_apollo_build]}/apollo-config.groovy") - parse_apollo_config("#{config[:web_apollo_build]}/apollo-config.groovy",config) - if(defined?(addCodonString).nil?) - open("#{config[:web_apollo_build]}/apollo-config.groovy", 'a') { |f| - f << "// default apollo settings\n" - f << "apollo {\n" - f << "get_translation_code = #{@addCodonString}\n" - f << "}\n" - } - end - - #Create a new database for this installation - puts "Create the database #{config[:web_apollo_db]}" - system("sudo su - postgres -c \"createdb -E UTF-8 -O #{config[:pguser]} #{config[:web_apollo_db]}\"") - - - # Build the webapollo installation - Dir.chdir(config[:web_apollo_build]) do - system("./apollo deploy") - end - - # Copy the packaged WebApollo installation to the Tomcat folder - system("cp #{config[:web_apollo_build]}/target/apollo*.war #{tomcat_apps}/#{@name}.war") - - #Final message: - puts "Congratulation ! Installation done. You can retrieve your installation on the webpage http://annotation-prod.scilifelab.se:8080/#{@name}" - -end - diff --git a/annotation/tools/webapollo/apollo2/gaas_manage_species.rb b/annotation/tools/webapollo/apollo2/gaas_manage_species.rb deleted file mode 100755 index b057a0ce0..000000000 --- a/annotation/tools/webapollo/apollo2/gaas_manage_species.rb +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/ruby -# == NAME -# build.rb -# -# == USAGE -# ./this_script.rb [ -h | --help ] -# [ -i | --infile ] |[ -o | --outfile ] | -# == DESCRIPTION -# A script to build a new WebApollo installation based on pre-built template -# -# == OPTIONS -# -h,--help:: Show help -# -s,--species=SPECIES:: Name of the species -# -f,--fasta=FASTA:: Genome sequence -# -# == EXPERT OPTIONS -# -# == AUTHOR -# Marc Hoeppner, mphoeppner@gmail.com - -require 'optparse' -require 'ostruct' - -### Define modules and classes here - -def tomcat_group - - user_groups = `id` - user_groups.include?("tomcat") - -end - -### Get the script arguments and open relevant files -options = OpenStruct.new() -opts = OptionParser.new() -options.clean = false -opts.on("-s","--species", "=SPECIES","Species name") {|argument| options.species = argument } -opts.on("-f","--fasta", "=FASTA","Fasta file") {|argument| options.fasta = argument } -opts.on("-c","--[no]clean","Clean up project") { options.clean = true } -opts.on("-w","--wa_installation", "=wa_installation_name","path to the WA installation") {|argument| options.wa_installation_name = argument } -opts.on("-h","--help","Display the usage information") { - puts opts - exit -} - -opts.parse! - -raise "You are not member of the tomcat group and thus cannot deploy WebApollo!" unless tomcat_group - -@species = options.species or abort 'No species name provided' -@organism = options.species.split('_')[0].capitalize + ' ' + options.species.split('_')[-1] -@wa_installation_name = options.wa_installation_name or abort 'Name of the WebApollo installation not provided' -if options.clean != true - @fasta = options.fasta or abort 'No genome sequence provided' -end - -# Custom CSS styles needed for WA -CSS_STRING = ".plus-cigarM {\nbackground-color: green; /* color for plus matches */\n}\n\n.minus-cigarM {\nbackground-color: blue; /* color for minus matches */\n}\n" - -### Usernames, passwords and locations - -user = ENV['USER'] -home = ENV['HOME'] - -build_dir = ENV['APOLLO_BUILD_DIR'] or abort "Environment variable APOLLO_BUILD_DIR not set" -data_dir = ENV['APOLLO_DATA_DIR'] or abort "Environment vairable APOLLO_DATA_DIR not set" - -web_apollo_storage = "#{data_dir}/#{@species}" # Folder tree where data is stored - -config = { - :web_apollo_path => "#{build_dir}/#{@wa_installation_name}", # The location where this WA installation has been built - :tool_dir => "/opt/ucsc", # Location of blat and FaToNib -} - -### The workflow - -if options.clean == true - puts "Are you really sure to remove the species folder ? [y|n]:" - selection = STDIN.gets.chomp - if(selection.downcase == "y") - puts "Cleaning database" - system("#{config[:web_apollo_path]}/docs/web_services/examples/groovy/delete_annotations_from_organism.groovy -destinationurl http://localhost:8080/#{@wa_installation_name} -organismname #{@species}") - - puts "Cleaning webapollo folder" - system("rm -Rf #{web_apollo_storage}") - - puts "Cleaning finished" - else - puts "Fine we let everythong as it was." - end -else - #check if instalation already existing - if File.directory?("#{web_apollo_storage}") - puts "Instalation for species #{@species} already exits !" - exit - else - # Create the folder where the data is to be stored - puts "Create folders" - system("mkdir -p #{web_apollo_storage}") - system("chgrp -R tomcat #{web_apollo_storage}") # Must be owned by tomcat group - - # Load genome assembly - puts "Loading genome assembly" - system("#{config[:web_apollo_path]}/bin/prepare-refseqs.pl --fasta #{@fasta} --out #{web_apollo_storage}") - - - # Create custom CSS style sheet - f = File.new("#{web_apollo_storage}/custom.css","w") - f.puts CSS_STRING - f.close - - # Build Blat database - puts "Build Blat database" - system("#{config[:tool_dir]}/faToTwoBit #{@fasta} #{web_apollo_storage}/blat.2bit") - - end -end - diff --git a/annotation/tools/webapollo/terraform/README.md b/annotation/tools/webapollo/terraform/README.md deleted file mode 100644 index 4d9ee3705..000000000 --- a/annotation/tools/webapollo/terraform/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Deploy an instance on SSC with webapollo using Terraform - -## Usage - -1. create an ssh-key by - - ``` - mkdir -p private - ssh-keygen -q -t rsa -N "" -f private/webap.key - ``` - -2. Initialize terraform by - - `terraform init` - -3. Create a plain text file `terraform.tfvars` and define parameters, e.g. - - ``` - external_network_id="8a2049af-7ff7-4303-b794-a6387dfee03d" # id of the external network - floating_ip_pool = "Public External IPv4 Network" # name of the external floatig ip pool - - - size_volume = 100 # define size of block storage to be mounted in GB - - admin_username = "adminuser" - admin_password = "verystrongpassword" - ``` - -4. Set up Openstack credentials by sourcing an RC file from an SSC project - - `source ` - -5. Apply the deployment by - - `terraform apply` - - -After successful deployment, the webapollo server can be accessed at http://instance-ip:8888/ - diff --git a/annotation/tools/webapollo/terraform/localscripts/get-gaas.sh b/annotation/tools/webapollo/terraform/localscripts/get-gaas.sh deleted file mode 100755 index 08e37b69a..000000000 --- a/annotation/tools/webapollo/terraform/localscripts/get-gaas.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Fetch gaas - -mkdir -p tmp -if [ ! -d tmp/GAAS ]; then - git clone git@github.com:NBISweden/gaas.git tmp/GAAS -else - pushd tmp/GAAS - git pull - popd -fi - diff --git a/annotation/tools/webapollo/terraform/localscripts/get-sshkeys.sh b/annotation/tools/webapollo/terraform/localscripts/get-sshkeys.sh deleted file mode 100755 index 83e6dbc02..000000000 --- a/annotation/tools/webapollo/terraform/localscripts/get-sshkeys.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# Retrieve common SSH keys from the repo - -mkdir -p tmp -if [ ! -d tmp/annotation-cluster ]; then - git clone git@github.com:NBISweden/annotation-cluster.git tmp/annotation-cluster -else - pushd tmp/annotation-cluster - git pull - popd -fi - diff --git a/annotation/tools/webapollo/terraform/main.tf b/annotation/tools/webapollo/terraform/main.tf deleted file mode 100644 index 40bfdfe9e..000000000 --- a/annotation/tools/webapollo/terraform/main.tf +++ /dev/null @@ -1,197 +0,0 @@ -data "external" "agent_keys" { - program = ["bash", "-c", "ssh-add -L | grep -v cert | jq -R -s 'split(\"\\n\")[:-1] | map({ \"key\" : . }) | .[0]'" ] -} - -resource "openstack_compute_keypair_v2" "my-cloud-key" { - name = "${var.keypair_name}${var.project_suffix}" - public_key = data.external.agent_keys.result.key -} - -resource "openstack_networking_network_v2" "net_webap" { - name = "${var.internal_network_name}${var.project_suffix}" - admin_state_up = "true" -} - -resource "openstack_networking_subnet_v2" "subnet_webap" { - name = "${var.internal_subnet_name}${var.project_suffix}" - network_id = openstack_networking_network_v2.net_webap.id - cidr = "10.0.0.0/24" - ip_version = 4 - dns_nameservers = ["8.8.8.8"] - enable_dhcp = "true" -} - -data "openstack_networking_network_v2" "externalnetwork" { - name = var.external_network_name -} - -resource "openstack_networking_router_v2" "router_webap" { - name = "${var.router_name}${var.project_suffix}" - admin_state_up = "true" - external_network_id = data.openstack_networking_network_v2.externalnetwork.id -} - -resource "openstack_networking_router_interface_v2" "router_interface" { - router_id = openstack_networking_router_v2.router_webap.id - subnet_id = openstack_networking_subnet_v2.subnet_webap.id -} - - - -resource "openstack_compute_secgroup_v2" "secgroup_webap" { - name = "${var.secgroup_name}${var.project_suffix}" - description = "security group ${var.project_suffix}" - - rule { - from_port = 22 - to_port = 22 - ip_protocol = "tcp" - cidr = "0.0.0.0/0" - } - rule { - from_port = 443 - to_port = 443 - ip_protocol = "tcp" - cidr = "0.0.0.0/0" - } - - rule { - from_port = 80 - to_port = 80 - ip_protocol = "tcp" - cidr = "0.0.0.0/0" - } - rule { - from_port = 8080 - to_port = 8080 - ip_protocol = "tcp" - cidr = "0.0.0.0/0" - } - rule { - from_port = 8888 - to_port = 8888 - ip_protocol = "tcp" - cidr = "0.0.0.0/0" - } -} - -resource "openstack_networking_port_v2" "port_webap" { - name = "${var.port_name}${var.project_suffix}" - network_id = openstack_networking_network_v2.net_webap.id - admin_state_up = "true" - security_group_ids = [openstack_compute_secgroup_v2.secgroup_webap.id] - - fixed_ip { - subnet_id = openstack_networking_subnet_v2.subnet_webap.id - ip_address = "10.0.0.10" - } -} - -resource "openstack_networking_floatingip_v2" "ip_webap" { - pool = var.external_network_name -} - -resource "openstack_blockstorage_volume_v2" "vol_webap" { - name = "vol_webap${var.project_suffix}" - size = var.size_volume -} - - - - -resource "openstack_compute_instance_v2" "instance_webap" { - depends_on = [openstack_networking_subnet_v2.subnet_webap] - name = "${var.instance_name}${var.project_suffix}" - image_name = var.image_name - flavor_name = var.flavor_name - key_pair = openstack_compute_keypair_v2.my-cloud-key.id - security_groups = [openstack_compute_secgroup_v2.secgroup_webap.id ] - - network { - name = "${var.internal_network_name}${var.project_suffix}" - } - -} - -resource "openstack_compute_volume_attach_v2" "volume_attachement_1" { - instance_id = openstack_compute_instance_v2.instance_webap.id - volume_id = openstack_blockstorage_volume_v2.vol_webap.id -} - - -resource "openstack_compute_floatingip_associate_v2" "ip_webap" { - floating_ip = openstack_networking_floatingip_v2.ip_webap.address - instance_id = openstack_compute_instance_v2.instance_webap.id - fixed_ip = openstack_compute_instance_v2.instance_webap.network[0].fixed_ip_v4 -} - -resource "null_resource" "provision" { - depends_on = [openstack_compute_floatingip_associate_v2.ip_webap] - connection { - type = "ssh" - user = var.ssh_user - agent = "true" - timeout = "5m" - host = openstack_networking_floatingip_v2.ip_webap.address - } - - provisioner "local-exec" { - command = "bash localscripts/get-sshkeys.sh" - } - provisioner "local-exec" { - command = "bash localscripts/get-gaas.sh" - } - -provisioner "file" { - source = "tmp/annotation-cluster/ansible-ubuntu-18.04/roles/common/files/authorized-keys" - destination = "/home/${var.ssh_user}" - } - -provisioner "remote-exec" { - inline = [ "mkdir -p /home/${var.ssh_user}/nbis", - "mkdir -p /home/${var.ssh_user}/setup", - ] -} - -provisioner "file" { - source = "tmp/GAAS" - destination = "/home/${var.ssh_user}/nbis" - } - -provisioner "file" { - source = "remotescripts/" - destination = "/home/${var.ssh_user}/setup" - } - -provisioner "remote-exec" { - inline = [ - "set -x -e", - "PATH=$PATH:/snap/bin", - "sudo apt update", - "sudo DEBIAN_FRONTEND=noninteractive apt dist-upgrade -y", - "sudo DEBIAN_FRONTEND=noninteractive apt install -y ruby groovy", - "bash $HOME/setup/add-sshkeys.sh", - "bash $HOME/setup/fix_repo_permissions.sh", - "bash $HOME/setup/mount_volume.sh ${var.project_suffix}", - "bash $HOME/setup/install_docker.sh", - "bash $HOME/setup/install_conda.sh", - "echo ${var.admin_password} > ~/nbis/GAAS/annotation/tools/webapollo/apollo/apolloadminpassword", - "echo APOLLO_DATA_DIR=\"$(echo /mnt/*/data)\" >> $HOME/.bashrc", - "echo export APOLLO_DATA_DIR >> $HOME/.bashrc" - ] -} - -# Do a new connection to pick up groups. - -provisioner "remote-exec" { - inline = [ - "bash $HOME/nbis/GAAS/annotation/tools/webapollo/apollo/run_webapollo.sh" -] -} - -} -output "connection-string" { - description = "To run, connect to" - value = "${var.ssh_user}@${openstack_networking_floatingip_v2.ip_webap.address}" -} - diff --git a/annotation/tools/webapollo/terraform/providers.tf b/annotation/tools/webapollo/terraform/providers.tf deleted file mode 100644 index 97782c81b..000000000 --- a/annotation/tools/webapollo/terraform/providers.tf +++ /dev/null @@ -1,4 +0,0 @@ -provider "openstack" {} -provider "docker" { - host = "tcp://127.0.0.1:2376/" -} diff --git a/annotation/tools/webapollo/terraform/remotescripts/add-sshkeys.sh b/annotation/tools/webapollo/terraform/remotescripts/add-sshkeys.sh deleted file mode 100755 index c4875c04d..000000000 --- a/annotation/tools/webapollo/terraform/remotescripts/add-sshkeys.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Add SSH keys - -if [ -d ~/authorized-keys -a ~/.ssh ];then - cat ~/authorized-keys/*.pub >> ~/.ssh/authorized_keys - chmod 600 ~/.ssh/authorized_keys - rm -rf ~/authorized-keys -fi - -cat - >>$HOME/.ssh/authorized_keys < /tmp/docker-compose; chmod +x /tmp/docker-compose; sudo cp /tmp/docker-compose /usr/local/bin/docker-compose -fi diff --git a/annotation/tools/webapollo/terraform/remotescripts/mount_volume.sh b/annotation/tools/webapollo/terraform/remotescripts/mount_volume.sh deleted file mode 100755 index c5d4eaca3..000000000 --- a/annotation/tools/webapollo/terraform/remotescripts/mount_volume.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -LABEL="$1" -LABEL=${LABEL:-sequence} -LABEL=$(echo $LABEL | tr -c -d '[a-z0-9]') - -mountpath=/mnt/$LABEL - -if mount | grep -q "$mountpath" ; then - exit 0 -fi - -sudo mkdir -p "$mountpath" -sudo mkfs.ext4 -L "$LABEL" /dev/vdb -echo "LABEL=$LABEL $mountpath ext4 defaults,noatime,_netdev,nofail 0 2" | sudo tee --append /etc/fstab -sudo mount -a -sudo chown "$USER" "$mountpath" -echo "$LABEL" > "$mountpath/species" diff --git a/annotation/tools/webapollo/terraform/remotescripts/run_docker.sh b/annotation/tools/webapollo/terraform/remotescripts/run_docker.sh deleted file mode 100755 index d6dbb2db2..000000000 --- a/annotation/tools/webapollo/terraform/remotescripts/run_docker.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -usage=" -USAGE: $0 --admin admin_username --password admin_password - -" -admin_username= -admin_password= - -if [ $# -lt 1 ]; then - echo "$usage" - exit 1 -fi - -isNonOptionArg=false -while [ "$1" != "" ]; do - if [ "$isNonOptionArg" == "true" ]; then - isNonOptionArg=false - elif [ "$1" == "--" ]; then - isNonOptionArg=true - elif [ "${1:0:1}" == "-" ]; then - case $1 in - -h| --help) echo "$usage"; exit;; - --admin) admin_username=$2;shift;; - --password) admin_password=$2;shift;; - -*) echo "Error! Wrong argument: $1">&2; exit;; - esac - fi - shift -done - -if [ "$admin_username" == "" -o "$admin_password" == "" ];then - echo "$usage" - exit 1 -fi - -pushd /media/storage -mkdir -p software -pushd software -git clone https://github.com/NBISweden/GAAS - - -sudo docker run --name webapollo -d -e CATALINA_OPTS=-Xmx14G -e APOLLO_ADMIN_EMAIL=$admin_username -e APOLLO_ADMIN_PASSWORD=$admin_password -v /mnt/sequences/data/:/data -v /mnt/sequences/postgres-data/:/var/lib/postgresql -p 8888:8080 gmod/apollo:latest diff --git a/annotation/tools/webapollo/terraform/terraform.tfvars b/annotation/tools/webapollo/terraform/terraform.tfvars deleted file mode 100644 index 9d7281aec..000000000 --- a/annotation/tools/webapollo/terraform/terraform.tfvars +++ /dev/null @@ -1,9 +0,0 @@ - -external_network_name = "Public External IPv4 Network" # name of the external floatig ip pool - -size_volume = 10 # define size of block storage to be mounted in GB - -admin_password = "Losenord" -project_suffix = "_species_name" - -flavor_name = "ssc.medium" diff --git a/annotation/tools/webapollo/terraform/variables.tf b/annotation/tools/webapollo/terraform/variables.tf deleted file mode 100644 index 65ff4a961..000000000 --- a/annotation/tools/webapollo/terraform/variables.tf +++ /dev/null @@ -1,72 +0,0 @@ -variable external_network_name { - description = "Name of the external network" - default = "Public External IPv4 Network" -} -variable internal_network_name { - description = "Name of the internal network" - default = "net_webapollo" -} -variable internal_subnet_name { - description = "Name of the internal subnet" - default = "subnet_webapollo" -} -variable port_name { - description = "Name of the port" - default = "port_webapollo" -} -variable router_name { - description = "Name of the router_name" - default = "router_webapollo" -} -variable ssh_user { - description = "SSH user name (use the default user for the OS image)" - default = "ubuntu" -} -variable private_ssh_key { - description = "Local path to the private SSH key" - default = "./private/webapollo.key" -} -variable public_ssh_key { - description = "Local path to the public SSH key" - default = "./private/webapollo.key.pub" -} - -variable image_name { - description = "Name of the image for the instance" - default = "Ubuntu 18.04 LTS (Bionic Beaver) - latest" -} -variable flavor_name { - description = "Name of the image for the instance" - default = "ssc.large" -} -variable instance_name { - description = "Name for the instance" - default = "webapollo" -} -variable keypair_name { - description = "Name of keypair" - default = "key-webapollo" -} -variable secgroup_name { - description = "Name of seurity group" - default = "secgroup-webapollo" -} -variable size_volume { - description = "size of the volume to be attached to the instance" - default = 100 -} -variable git_common_keys { - description = "git repo containing common ssh keys" - default = "git@github.com:NBISweden/annotation-cluster.git" -} -variable admin_username { - description = "Name of the admin user to webapollo" - default = "admin@nbis.se" -} -variable admin_password { - description = "Password of the admin user to webapollo" -} -variable project_suffix { - description = "project suffix added to all resource names" - default = "" -} diff --git a/annotation/tools/webapollo/terraform/versions.tf b/annotation/tools/webapollo/terraform/versions.tf deleted file mode 100644 index b33c48326..000000000 --- a/annotation/tools/webapollo/terraform/versions.tf +++ /dev/null @@ -1,11 +0,0 @@ -terraform { - required_providers { - openstack = { - source = "terraform-provider-openstack/openstack" - } - docker = { - source = "terraform-providers/docker" - } - } - required_version = ">= 0.13" -}