[med-svn] [kmc] 03/03: Cleanup of dumper statements from usage_to_man script
Jorge Soares
jssoares-guest at moszumanska.debian.org
Tue Nov 18 15:17:22 UTC 2014
This is an automated email from the git hooks/post-receive script.
jssoares-guest pushed a commit to branch master
in repository kmc.
commit 75b0f47d8a6641841e8b3e4ef3bc026cb7ce1df7
Author: Jorge Soares <j.s.soares at gmail.com>
Date: Tue Nov 18 15:17:06 2014 +0000
Cleanup of dumper statements from usage_to_man script
---
debian/usage_to_man | 183 ++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 134 insertions(+), 49 deletions(-)
diff --git a/debian/usage_to_man b/debian/usage_to_man
index e69a4bb..33017ab 100755
--- a/debian/usage_to_man
+++ b/debian/usage_to_man
@@ -3,15 +3,15 @@ use strict;
use warnings;
use Data::Dumper;
-#Converts Fastaq python scripts usage into man pages.
-#The man pages are placed in the man folder of the main Fastaq directory
+#Converts KMC usage into man pages. It's a bigger script than the man pages, but the plan is to have a future script that works for all packages
+#The man pages are placed in the man folder in the main directory of the kmc package
createManPages();
sub createManPages {
my $source= 'bin';
- my $destination= '.';
+ my $destination= 'man';
my $app_name = 'KMC';
@@ -37,8 +37,11 @@ sub createManPages {
$man_file = $destination . '/' . $man_file . '.1';
- my $kmc_short_description = 'Count kmers in genomic sequences';
- my $kmc_long_description = 'KMC—K-mer Counter is a utility designed for counting k-mers (sequences of consecutive k symbols) in a set of reads from genome sequencing projects.';
+ my $kmc_short_description = q{Count kmers in genomic sequences};
+ my $kmc_long_description = q{KMC—K-mer Counter is a utility designed for counting k-mers (sequences of consecutive k symbols) in a set of reads from genome sequencing projects.};
+
+ my $kmc_dump_short_description = q{List k-mers from kmc-generated database};
+ my $kmc_dump_long_description = q{KMC's end product is a database of k-mers stored in compact binary form. The kmc_dump program allows the production of a textual list of k-mers together with their counters for the analysis ran};
my $cmd = "help2man -N -m $filename -n $filename --no-discard-stderr $file | sed 's/usage://gi'";
@@ -49,68 +52,142 @@ sub createManPages {
$line =~ s/\n$//;
}
- my $ss_param_seen = 0;
- my $ss_param_seen2 = 1;
- my $ip_tag_seen = 0;
+
my @lines_not_to_print;
my @lines_to_print;
+ if ($filename eq 'kmc') {
+ my $ss_param_seen = 0;
+ my $ss_param_seen2 = 1;
+ my $ip_tag_seen = 0;
- for (my $i = 0; $i < scalar @output; $i++) {
+ for (my $i = 0; $i < scalar @output; $i++) {
- my $output_line = $output[$i];
+ my $output_line = $output[$i];
- $output_line =~ s/^(\.TH\s)([a-zA-Z0-9-]+)(\s.*)/$1 $filename $3/;
- $output_line =~ s/^(K\-Mer \\- )(kmc)/$2 - $kmc_short_description/;
- if ($output_line =~ m/^K\\-Mer Counter/) {
- $output_line = $kmc_long_description;
- }
-
- if ($output_line =~ m/^\.SS \"Parameters\:\"/ && ! $ss_param_seen) {
- push(@lines_not_to_print, $i);
- push(@lines_not_to_print, $i + 1);
- push(@lines_not_to_print, $i + 2);
- push(@lines_not_to_print, $i + 3);
+ if ($output_line =~ m/^(\.TH\s)([a-zA-Z0-9-]+)(\s.*)/) {
+ $output_line = $1 . uc($filename) . $3;
+ }
+ $output_line =~ s/^(K\-Mer \\- )(kmc)/$2 - $kmc_short_description/;
+ if ($output_line =~ m/^K\\-Mer Counter/) {
+ $output_line = $kmc_long_description;
+ }
+
+ if ($output_line =~ m/^\.SS \"Parameters\:\"/ && ! $ss_param_seen) {
+ push(@lines_not_to_print, $i);
+ push(@lines_not_to_print, $i + 1);
+ push(@lines_not_to_print, $i + 2);
+ push(@lines_not_to_print, $i + 3);
- $ss_param_seen = 1;
- $ss_param_seen2 = 0;
+ $ss_param_seen = 1;
+ $ss_param_seen2 = 0;
- }
- elsif ($output_line =~ m/^\.IP/ && ! $ip_tag_seen) {
- $output_line = '.SH SYNOPSIS';
- if ($output[$i + 2] =~ /^kmc/) {
- $output[$i +2] = ".PP\n" . $output[$i + 2];
}
- $ip_tag_seen = 1;
- }
- elsif ($output_line =~ m/^\.SS ""/) {
- push(@lines_not_to_print, $i);
- push(@lines_not_to_print, $i + 1);
- push(@lines_not_to_print, $i + 2);
- push(@lines_not_to_print, $i + 3);
- }
- elsif ($output_line =~ m/^Example:/) {
- $output_line = '.SH EXAMPLES';
- $output[$i + 2] = ".PP\n" . $output[$i + 2];
+ elsif ($output_line =~ m/^\.IP/ && ! $ip_tag_seen) {
+ $output_line = '.SH SYNOPSIS';
+ if ($output[$i + 2] =~ /^kmc/) {
+ $output[$i +2] = ".PP\n" . $output[$i + 2];
+ }
+ $ip_tag_seen = 1;
+ }
+ elsif ($output_line =~ m/^\.SS ""/) {
+ push(@lines_not_to_print, $i);
+ push(@lines_not_to_print, $i + 1);
+ push(@lines_not_to_print, $i + 2);
+ push(@lines_not_to_print, $i + 3);
+ }
+ elsif ($output_line =~ m/^Example:/) {
+ $output_line = '.SH EXAMPLES';
+ $output[$i + 2] = ".PP\n" . $output[$i + 2];
- }
- elsif ($output_line =~ m/^\.SS \"Parameters\:\"/ && $ss_param_seen && ! $ss_param_seen2) {
- last;
+ }
+ elsif ($output_line =~ m/^\.SS \"Parameters\:\"/ && $ss_param_seen && ! $ss_param_seen2) {
+ last;
+
+ }
+
+ if ( ! grep( /^$i$/, @lines_not_to_print ) ){
+ #print "$output_line\n";
+ push(@lines_to_print, $output_line);
+ }
- }
- if ( ! grep( /^$i$/, @lines_not_to_print ) ){
- #print "$output_line\n";
- push(@lines_to_print, $output_line);
}
+ }
+ elsif ($filename eq 'kmc_dump') {
+
+ my $seen_kmc_start = 0;
+ my $seen_parameters = 0;
+ my $seen_options = 0;
+ my $synopsis_seen = 0;
+ my @parameters_lines;
+ my @options_lines;
+ for (my $i = 0; $i < scalar @output; $i++) {
+ my $output_line = $output[$i];
+ if($output_line =~ m/^(\.TH\s)([a-zA-Z0-9-]+)(\s.*)/ ) {
+ $output_line = $1 . uc($filename) . $3;
+ }
+ $output_line =~ s/^(KMC \\- )(kmc_dump)/$2 - $kmc_dump_short_description/;
+ if ($output_line =~ m/^KMC dump ver\./) {
+ $output_line = $kmc_dump_long_description;
+ $seen_kmc_start = 1;
+ }
+ if ($output_line =~ m/^kmc/ && $seen_kmc_start == 1 && ! $synopsis_seen) {
+ $output_line = "\.SH SYNOPSIS\n$output_line";
+ $synopsis_seen = 1;
+ }
+ if ($output_line =~ m/^kmc/ && $seen_kmc_start == 1 && $synopsis_seen) {
+ push(@lines_not_to_print, $i);
+ push(@lines_not_to_print, $i + 1);
+
+ }
+ if($output_line =~ m/Parameters:/ && ! $seen_parameters) {
+ push(@parameters_lines, '.PP');
+ push(@parameters_lines, $output_line);
+ push(@parameters_lines, '.PP');
+ push(@parameters_lines, $output[$i + 1]);
+ push(@lines_not_to_print, $i);
+ push(@lines_not_to_print, $i + 1);
+ $seen_parameters = 1;
+ }
+ if($output_line =~ m/Parameters:/ && $seen_parameters) {
+ push(@lines_not_to_print, $i);
+ push(@lines_not_to_print, $i + 1);
+ }
+ if($output_line =~ m/Options:/ && ! $seen_options) {
+ push(@options_lines, '.SH OPTIONS');
+ push(@options_lines, $output[$i + 1]);
+ push(@options_lines, '.PP');
+ push(@options_lines, $output[$i + 2]);
+ push(@lines_not_to_print, $i);
+ push(@lines_not_to_print, $i + 1);
+ push(@lines_not_to_print, $i + 2);
+ $seen_options = 1;
+ }
+ if($output_line =~ m/Options:/ && $seen_options) {
+ push(@lines_not_to_print, $i);
+ push(@lines_not_to_print, $i + 1);
+ push(@lines_not_to_print, $i + 2);
+ }
+ if ( ! grep( /^$i$/, @lines_not_to_print ) ){
+ push(@lines_to_print, $output_line);
+ }
+ }
+ for my $line(@options_lines) {
+ push(@lines_to_print, $line);
+ }
+ for my $line(@parameters_lines) {
+ push(@lines_to_print, $line);
+ }
+
}
- print Dumper(\@lines_not_to_print);
open (my $man_fh, ">", $man_file);
for my $line(@lines_to_print) {
print $man_fh "$line\n";
}
+ writeAuthorAndCopyright($man_fh,$filename);
close($man_fh);
print "Manpage creation complete\n";
}
@@ -124,7 +201,15 @@ sub writeAuthorAndCopyright {
my $author_blurb = <<END_OF_AUTHOR_BLURB;
.SH "AUTHOR"
.sp
-$filename was originally written by Martin Hunt (mh12\@sanger.ac.uk)
+$filename was originally written by:
+.PP
+Sebastian Deorowicz (sebastian.deorowicz\@polsl.pl)
+.PP
+Marek Kokot
+.PP
+Szymon Grabowski
+.PP
+Agnieszka Debudaj-Grabysz
END_OF_AUTHOR_BLURB
print $man_fh "$author_blurb\n";
@@ -132,7 +217,7 @@ END_OF_AUTHOR_BLURB
my $copyright_blurb = <<'END_OF_C_BLURB';
.SH "COPYING"
.sp
-Wellcome Trust Sanger Institute Copyright \(co 2013 Wellcome Trust Sanger Institute This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version\&.
+KMC is a free software distributed under GNU GPL3 licence for academic, research, and commercial use.
END_OF_C_BLURB
print $man_fh "$copyright_blurb\n";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/kmc.git
More information about the debian-med-commit
mailing list