Skip to content

Commit

Permalink
Add CLI tutorial stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
olsonanl committed Oct 19, 2017
1 parent a7093ae commit de6dd10
Show file tree
Hide file tree
Showing 65 changed files with 6,178 additions and 2 deletions.
57 changes: 57 additions & 0 deletions cli/p3-script-list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
p3-all-drugs.pl
p3-all-genomes.pl
p3-blast.pl
p3-build-kmer-db.pl
p3-count.pl
p3-echo.pl
p3-extract-gto.pl
p3-extract.pl
p3-feature-gap.pl
p3-feature-upstream.pl
p3-file-filter.pl
p3-find-couples.pl
p3-find-features.pl
p3-find-in-clusters.pl
p3-format-results.pl
p3-function-to-role.pl
p3-generate-close-roles.pl
p3-generate-clusters.pl
p3-genome-fasta.pl
p3-get-drug-genomes.pl
p3-get-family-data.pl
p3-get-family-features.pl
p3-get-feature-data.pl
p3-get-feature-group.pl
p3-get-feature-sequence.pl
p3-get-features-by-sequence.pl
p3-get-genome-contigs.pl
p3-get-genome-data.pl
p3-get-genome-drugs.pl
p3-get-genome-features.pl
p3-get-genome-group.pl
p3-gto-dna.pl
p3-gto-fasta.pl
p3-gto-scan.pl
p3-gto.pl
p3-join.pl
p3-kmer-compare.pl
p3-list-feature-groups.pl
p3-list-genome-groups.pl
p3-login.pl
p3-match.pl
p3-merge.pl
p3-pick.pl
p3-project-subsystems.pl
p3-put-feature-group.pl
p3-put-genome-group.pl
p3-rast.pl
p3-related-by-clusters.pl
p3-rep-prots.pl
p3-sequence-profile.pl
p3-set-to-relation.pl
p3-signature-clusters.pl
p3-signature-families.pl
p3-signature-peginfo.pl
p3-sort.pl
p3-stats.pl
p3-tbl-to-fasta.pl
84 changes: 84 additions & 0 deletions cli/transform-p3-scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#
# Read the p3-scripts list; pull the data from github;
# transform to restructured text and place into the correct location.
#

use strict;
use File::Slurp;
use File::Temp;
use Data::Dumper;
use LWP::UserAgent;
use Pod::POM;
use Pod::POM::View::Restructured;
use File::Basename;

my %link_map = ('P3Utils/ih_options' => ":ref:`cli-input-options`",
'P3Utils::ih_options' => ":ref:`cli-input-options`",
'P3Utils/data_options' => ":ref:`cli-data-options`",
'P3Utils/col_options' => ":ref:`cli-column-options`",
'P3Utils/delim_options' => ":ref:`cli-delimiter-options`",
);

my $ua = LWP::UserAgent->new;

my $url_base = "https://raw.githubusercontent.com/SEEDtk/RASTtk/master/scripts";
my $out_base = "../docroot/cli_tutorial/command_list";

open(S, "<", "p3-script-list.txt") or die "Cannot open p3-script-list.txt: $!";

my $conv = Pod::POM::View::Restructured->new({namespace => 'cli'});

my %unmapped_links;

while (my $script = <S>)
{
chomp $script;
print "$script\n";
my $url = "$url_base/$script";
my $res = $ua->get($url);
if (!$res->is_success)
{
die "Error " . $res->code . " fetching $url: " . $res->content;
}

my $txt = $res->content;
my $tmp = File::Temp->new();
print $tmp $txt;
close($tmp);

my $base = basename($script, ".pl");
my $out_file = "$out_base/$base.rst";

$conv->convert_file("$tmp", $base, $out_file, { link => \&handle_link });
}

if (%unmapped_links)
{
print STDERR "Unmapped links:\n";
for my $l (sort keys %unmapped_links)
{
print STDERR "\t$l\n";
}
}

sub handle_link
{
my($txt) = @_;

my $link = $link_map{$txt};

if (defined($link))
{
return ('', $link);
}
elsif ($txt =~ /^(p3.*)\.pl$/)
{
return ('', ":ref:`cli::$1`");
}
else
{
$unmapped_links{$txt}++;
return $txt;
}

}
28 changes: 28 additions & 0 deletions cli/update-script-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env perl

#
# Update the script-list file from the list in git that Bruce keeps.
#

use strict;
use LWP::UserAgent;

my $url = 'https://raw.githubusercontent.com/SEEDtk/Web/master/Web/Tutorials/p3_script_list.html';

my $ua = LWP::UserAgent->new;

my $res = $ua->get($url);

if (!$res->is_success)
{
die "Error " . $res->code . " fetching $url: " . $res->content;
}

open(O, ">", "p3-script-list.txt") or die "Cannot write p3-script-list.txt: $!";

my $txt = $res->content;
while ($txt =~ /module=([^"]+\.pl)/mg)
{
print O "$1\n";
}
close(O);
Loading

0 comments on commit de6dd10

Please sign in to comment.