Skip to content

Commit

Permalink
Merge pull request #13 from cancerit/feature/prerelease_n_basic_tests
Browse files Browse the repository at this point in the history
Feature/prerelease n basic tests
  • Loading branch information
Angela Matchan committed Mar 3, 2016
2 parents 502a916 + ec47887 commit 212c64d
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
/README.md
/perl/MYMETA.json
/perl/MYMETA.yml
/perl/docs/
/perl/perltidy.LOG
70 changes: 70 additions & 0 deletions perl/MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
bin/compare_CN_and_fusion.pl
bin/compare_overlapping_fusions.pl
bin/defuse.pl
bin/filter_fusions.pl
bin/process_qcstats.pl
bin/star_fusion.pl
bin/star_mapping.pl
bin/tophat_add_strand.pl
bin/tophat_fusion.pl
config/defuse.ini
config/star.ini
config/tophat.ini
docs.tar.gz
docs/pod_html/_blkbluw.css
docs/pod_html/_blkcynw.css
docs/pod_html/_blkgrng.css
docs/pod_html/_blkmagw.css
docs/pod_html/_grygrnk.css
docs/pod_html/_grygrnw.css
docs/pod_html/_podly.js
docs/pod_html/_whtgrng.css
docs/pod_html/_whtnavk.css
docs/pod_html/_whtprpk.css
docs/pod_html/_whtpurk.css
docs/pod_html/compare_overlapping_fusions.html
docs/pod_html/defuse.html
docs/pod_html/filter_fusions.html
docs/pod_html/index.html
docs/pod_html/star_fusion.html
docs/pod_html/star_mapping.html
docs/pod_html/tophat_add_strand.html
docs/pod_html/tophat_fusion.html
docs/reports_html/common.js
docs/reports_html/cover.14
docs/reports_html/cover.css
docs/reports_html/coverage.html
docs/reports_html/css.js
docs/reports_html/index.html
docs/reports_html/lib-Sanger-CGP-CgpRna-pm--subroutine.html
docs/reports_html/lib-Sanger-CGP-CgpRna-pm.html
docs/reports_html/lib-Sanger-CGP-CompareFusions-FusionAnnotation-pm--branch.html
docs/reports_html/lib-Sanger-CGP-CompareFusions-FusionAnnotation-pm--subroutine.html
docs/reports_html/lib-Sanger-CGP-CompareFusions-FusionAnnotation-pm.html
docs/reports_html/lib-Sanger-CGP-CompareFusions-Implement-pm--branch.html
docs/reports_html/lib-Sanger-CGP-CompareFusions-Implement-pm--subroutine.html
docs/reports_html/lib-Sanger-CGP-CompareFusions-Implement-pm.html
docs/reports_html/lib-Sanger-CGP-Defuse-Implement-pm--branch.html
docs/reports_html/lib-Sanger-CGP-Defuse-Implement-pm--subroutine.html
docs/reports_html/lib-Sanger-CGP-Defuse-Implement-pm.html
docs/reports_html/lib-Sanger-CGP-RnaQC-Implement-pm--branch.html
docs/reports_html/lib-Sanger-CGP-RnaQC-Implement-pm--subroutine.html
docs/reports_html/lib-Sanger-CGP-RnaQC-Implement-pm.html
docs/reports_html/lib-Sanger-CGP-Star-Implement-pm--branch.html
docs/reports_html/lib-Sanger-CGP-Star-Implement-pm--subroutine.html
docs/reports_html/lib-Sanger-CGP-Star-Implement-pm.html
docs/reports_html/standardista-table-sorting.js
docs/reports_text/coverage.txt
lib/Sanger/CGP/CgpRna.pm
lib/Sanger/CGP/CompareFusions/FusionAnnotation.pm
lib/Sanger/CGP/CompareFusions/Implement.pm
lib/Sanger/CGP/Defuse/Implement.pm
lib/Sanger/CGP/RnaQC/Implement.pm
lib/Sanger/CGP/Star/Implement.pm
lib/Sanger/CGP/Tophat/Implement.pm
Makefile.PL
MANIFEST This list of files
perltidy.LOG
t/1_pm_compile.t
t/2_pl_compile.t
t/data/tst.txt
4 changes: 0 additions & 4 deletions perl/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@


use ExtUtils::MakeMaker;
use File::ShareDir::Install;

WriteMakefile(
NAME => 'cgpRna',
Expand All @@ -50,6 +49,3 @@ WriteMakefile(
'File::Which' => 1.09,
}
);

package MY;
use File::ShareDir::Install qw( postamble );
Binary file added perl/docs.tar.gz
Binary file not shown.
56 changes: 56 additions & 0 deletions perl/t/1_pm_compile.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# this is a catch all to ensure all modules do compile
# added as lots of 'use' functionality is dynamic in pipeline
# and need to be sure that all modules compile.
# simple 'perl -c' is unlikely to work on head scripts any more.

use strict;
use Data::Dumper;
use Test::More;
use List::Util qw(first);
use File::Find;
use Cwd;
use Try::Tiny qw(try finally);
use File::Spec;

use FindBin qw($Bin);
my $lib_path = "$Bin/../lib";

# Add modules here that cannot be instantiated (should be extended and have no 'new')
# or need a set of inputs - these should be tested in own test script
use constant MODULE_SKIP => qw();


my $init_cwd = getcwd;

my @modules;
try {
chdir($lib_path);
find({ wanted => \&build_module_set, no_chdir => 1 }, './');
} finally {
chdir $init_cwd;
die "The try block died with: @_\n" if(@_);
};

for my $mod(@modules) {
use_ok($mod) or BAIL_OUT("Unable to 'use' module $mod");
}

for my $mod(@modules) {
ok($mod->VERSION, "Check version inheritance exists ($mod)");
if($mod->can('new')) { # only try new on things that have new defined
new_ok($mod) unless( first {$mod eq $_} MODULE_SKIP );
}
}

done_testing();

sub build_module_set {
if($_ =~ m/\.pm$/) {

my ($dir_str,$file) = (File::Spec->splitpath( $_ ))[1,2];
$file =~ s/\.pm$//;
my @dirs = File::Spec->splitdir( $dir_str );
shift @dirs;
push @modules, (join '::', @dirs).$file;
}
}
48 changes: 48 additions & 0 deletions perl/t/2_pl_compile.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# this is a catch all to ensure all modules do compile
# added as lots of 'use' functionality is dynamic in pipeline
# and need to be sure that all modules compile.
# simple 'perl -c' is unlikely to work on head scripts any more.

use strict;
use Data::Dumper;
use Test::More;
use List::Util qw(first);
use Try::Tiny qw(try catch);
use autodie qw(:all);
use File::Find;

use FindBin qw($Bin);
my $script_path = "$Bin/../bin";

use constant COMPILE_SKIP => qw();

my $perl = $^X;

my @scripts;
find({ wanted => \&build_path_set, no_chdir => 1 }, $script_path);

for(@scripts) {
my $script = $_;
if( first {$script =~ m/$_$/} COMPILE_SKIP ) {
note("SKIPPING: Script with known issues: $script");
next;
}
my $message = "Compilation check: $script";
my $command = "$perl -c $script";
my ($pid, $process);
try {
$pid = open $process, $command.' 2>&1 |';
while(<$process>){};
close $process;
pass($message);
}
catch {
fail($message);
};
}

done_testing();

sub build_path_set {
push @scripts, $_ if($_ =~ m/\.pl$/);
}
Empty file removed perl/t/data/tst.txt
Empty file.
56 changes: 56 additions & 0 deletions prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -eu # exit on first error or undefined value in subtitution
set -o pipefail

# get current directory
INIT_DIR=`pwd`

# get location of this file
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
if [ -z "$MY_PATH" ] ; then
# error; for some reason, the path is not accessible
# to the script (e.g. permissions re-evaled after suid)
echo Failed to determine location of script >2
exit 1 # fail
fi
# change into the location of the script
cd $MY_PATH/perl
rm -rf blib
rm -rf docs

echo '### Running perl tests ###'

export HARNESS_PERL_SWITCHES=-MDevel::Cover=-db,reports,-ignore,'t/.*\.t'
mkdir -p docs/reports_text
prove -w -I lib
echo
echo '### Generating test/pod coverage reports ###'
# removed 'condition' from coverage as '||' 'or' doesn't work properly
cover -coverage branch,subroutine,pod -report_c0 50 -report_c1 85 -report_c2 100 -report html_basic reports -silent
cover -coverage branch,subroutine,pod -report text reports -silent > docs/reports_text/coverage.txt
rm -rf reports/structure reports/digests reports/cover.13 reports/runs
cp reports/coverage.html reports/index.html
mv reports docs/reports_html
unset HARNESS_PERL_SWITCHES

echo '### Generating POD ###'
mkdir -p docs/pod_html
perl -MPod::Simple::HTMLBatch -e 'Pod::Simple::HTMLBatch::go' lib:bin docs/pod_html > /dev/null

echo '### Archiving docs folder ###'
tar cz -f docs.tar.gz docs

# generate manifest, and cleanup
echo '### Generating MANIFEST ###'
# delete incase any files are moved, the make target just adds stuff
rm -f MANIFEST
# cleanup things which could break the manifest
rm -rf install_tmp
perl Makefile.PL > /dev/null
make manifest &> /dev/null
rm -f Makefile MANIFEST.bak pm_to_blib MYMETA.*

# change back to original dir
cd $INIT_DIR
44 changes: 18 additions & 26 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ cd $INIT_DIR

# make sure that build is self contained
unset PERL5LIB
ARCHNAME=`perl -e 'use Config; print $Config{archname};'`
PERLROOT=$INST_PATH/lib/perl5
PERLARCH=$PERLROOT/$ARCHNAME
export PERL5LIB="$PERLROOT:$PERLARCH"
export PERL5LIB="$PERLROOT"

# Set PYTHONPATH as well so that RSeQC can be installed
unset PYTHONPATH
Expand Down Expand Up @@ -171,15 +169,12 @@ if [ -e $SETUP_DIR/star.success ]; then
else
(
cd $SETUP_DIR
set -x
if [ ! -e star ]; then
get_distro "star" $SOURCE_STAR
mkdir -p star
tar --strip-components 1 -C star -zxf star.tar.gz
fi
cp star/bin/Linux_x86_64/STAR $INST_PATH/bin/.
cp star/STAR-Fusion-*/STAR-Fusion $INST_PATH/bin/.
cp star/STAR-Fusion-*/lib/* $PERLROOT/.
get_distro "star" $SOURCE_STAR &&
mkdir -p star &&
tar --strip-components 1 -C star -zxf star.tar.gz &&
cp star/bin/Linux_x86_64/STAR $INST_PATH/bin/. &&
cp star/STAR-Fusion-*/STAR-Fusion $INST_PATH/bin/. &&
cp star/STAR-Fusion-*/lib/* $PERLROOT/. &&
touch $SETUP_DIR/star.success
)>>$INIT_DIR/setup.log 2>&1
fi
Expand All @@ -193,14 +188,11 @@ if [ -e $SETUP_DIR/rseqc.success ]; then
else
(
cd $SETUP_DIR
set -x
if [ ! -e rseqc ]; then
get_distro "rseqc" $SOURCE_RSEQC
mkdir -p rseqc
tar --strip-components 1 -C rseqc -zxf rseqc.tar.gz
fi
cd $SETUP_DIR/rseqc
python ./setup.py install --prefix=$INST_PATH
get_distro "rseqc" $SOURCE_RSEQC &&
mkdir -p rseqc &&
tar --strip-components 1 -C rseqc -zxf rseqc.tar.gz &&
cd $SETUP_DIR/rseqc &&
python ./setup.py install --prefix=$INST_PATH &&
touch $SETUP_DIR/rseqc.success
)>>$INIT_DIR/setup.log 2>&1
fi
Expand All @@ -227,11 +219,11 @@ done_message "" "Failed during installation of core dependencies."
# Install cgpRna code
echo -n "Installing cgpRna..."
(
cd $INIT_DIR/perl
perl Makefile.PL INSTALL_BASE=$INST_PATH
make
make test
make install
cd $INIT_DIR/perl &&
perl Makefile.PL INSTALL_BASE=$INST_PATH &&
make &&
make test &&
make install &&
cp $INIT_DIR/perl/config/star.ini $INST_PATH/config/
) >>$INIT_DIR/setup.log 2>&1
done_message "" "cgpRna install failed."
Expand All @@ -249,4 +241,4 @@ echo "Please add the following to beginning of PYTHONPATH:"
echo " $PYTHONROOT"
echo

exit 0
exit 0

0 comments on commit 212c64d

Please sign in to comment.