Skip to content

Commit

Permalink
Merge pull request #100 from sanger-pathogens/fix_validate_sample_man…
Browse files Browse the repository at this point in the history
…ifest

Fix validate sample manifest
  • Loading branch information
trstickland authored Jun 2, 2020
2 parents d66f52f + 71ab46e commit f485b29
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 16 deletions.
56 changes: 56 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM ubuntu:18.04
MAINTAINER = [email protected]

# dependency versions -- COULD specify these at build time
ARG VR_CODEBASE_VERSION=0.04
ARG CONFIG_GENERAL_VERSION=2.52

RUN apt-get update -qq -y
RUN apt-get upgrade -qq -y
RUN apt-get install -qq -y \
default-jdk \
build-essential \
git \
file \
wget \
curl \
libxml2-dev \
libexpat1-dev \
libgd-dev \
libssl-dev \
libdb-dev \
libmysqlclient-dev \
cpanminus \
locales \
genometools

RUN sed -i -e 's/# \(en_GB\.UTF-8 .*\)/\1/' /etc/locale.gen && \
touch /usr/share/locale/locale.alias && \
locale-gen
ENV LANG en_GB.UTF-8
ENV LANGUAGE en_GB:en
ENV LC_ALL en_GB.UTF-8

# dzil
RUN cpanm --notest \
Dist::Zilla \
Config::General@${CONFIG_GENERAL_VERSION}

# vr-codebase
RUN cd /opt \
&& wget -q https://github.com/sanger-pathogens/vr-codebase/archive/v${VR_CODEBASE_VERSION}.tar.gz \
&& tar xf v${VR_CODEBASE_VERSION}.tar.gz \
&& rm v${VR_CODEBASE_VERSION}.tar.gz
ENV PERL5LIB /opt/vr-codebase-${VR_CODEBASE_VERSION}/modules:$PERL5LIB

# bio-ena-datasubmission
RUN mkdir -p /opt/Bio-ENA-DataSubmission
COPY . /opt/Bio-ENA-DataSubmission
ENV PATH /opt/Bio-ENA-DataSubmission/bin:$PATH
ENV PERL5LIB /opt/Bio-ENA-DataSubmission/lib:$PERL5LIB
ENV ENA_SUBMISSIONS_DATA /opt/Bio-ENA-DataSubmission/data
RUN cd /opt/Bio-ENA-DataSubmission && dzil authordeps --missing | cpanm --notest
RUN cd /opt/Bio-ENA-DataSubmission && dzil listdeps --missing | grep -v 'VRTrack::Lane' | cpanm --notest

RUN cd /opt/Bio-ENA-DataSubmission && \
dzil test
12 changes: 7 additions & 5 deletions install-travis-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@ cpanm --notest Moose
cpanm --notest YAML::XS
cpanm --notest DBD::mysql


VRCODEBASE_GIT_URL='https://github.com/sanger-pathogens/vr-codebase.git'
VR_CODEBASE_VERSION=0.04
VRCODEBASE_GIT_URL="https://github.com/sanger-pathogens/vr-codebase/archive/v${VR_CODEBASE_VERSION}.tar.gz"

# Make an install location
if [ ! -d 'git_repos' ]; then
mkdir git_repos
fi
cd git_repos

git clone $VRCODEBASE_GIT_URL
wget -O- ${VRCODEBASE_GIT_URL} | tar xzvf -

#Add locations to PERL5LIB
VRCODEBASE_LIB=${start_dir}'/git_repos/vr-codebase/modules'
VRCODEBASE_LIB="${start_dir}/git_repos/vr-codebase-${VR_CODEBASE_VERSION}/modules"

export PERL5LIB=${VRCODEBASE_LIB}:$PERL5LIB

cd $start_dir
dzil authordeps --missing | cpanm --notest
dzil listdeps --missing | grep -v 'VRTrack::Lane' | cpanm --notest

dzil test

set +eu
set +x
set +x
16 changes: 10 additions & 6 deletions lib/Bio/ENA/DataSubmission/CommandLine/ValidateManifest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,21 @@ sub run {
my %taxon_id_to_ncbi_taxon_name;

my @errors_found;
foreach my $r (0 .. $#manifest) {
next unless (defined $manifest[$r]);
my $row_num = 0;
MANIFEST_ROW: foreach my $r (0 .. $#manifest) {
next MANIFEST_ROW unless (defined $manifest[$r]);
my @row = @{$manifest[$r]};
++$row_num;
my $missing_accessions_error = Bio::ENA::DataSubmission::Validator::Error::MandatorySampleAccession->new(
row => \@row,
mandatory => 0,
rownumber => $r
)->validate;
push(@errors_found, $missing_accessions_error) if ($missing_accessions_error->triggered);
next unless $#errors_found == -1;

if($missing_accessions_error->triggered) {
push(@errors_found, $missing_accessions_error);
warn "Manifest row $row_num has a missing accession number: NO FURTHER CHECKS will be done on this row";
next MANIFEST_ROW;
}
my $acc = $row[0];

# validate all generally
Expand All @@ -175,7 +179,7 @@ sub run {
}
}

# validate more specific cells separately
# validate mo re specific cells separately

# mandatory cells
my $mandatory = [ 4, 5, 14, 15, 16, 17, 19, 25, 28 ];
Expand Down
14 changes: 9 additions & 5 deletions t/Bio/ENA/DataSubmission/WEBINCli.t
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,15 @@ sub test_directory_not_a_directory {

# Check manifest validation when file is not readable
{
my $args = { %full_args };
$args->{'manifest'} = $unreadable_manifest;
my $under_test = Bio::ENA::DataSubmission::WEBINCli->new(%$args);
throws_ok {$under_test->run()} 'Bio::ENA::DataSubmission::Exception::CannotReadFile', "dies if manifest is not a readable file";

SKIP: {
skip "running as root, so disabled the test \"Check manifest validation when file is not readable\"", 1
if ('root' eq scalar(getpwuid $>));

my $args = { %full_args };
$args->{'manifest'} = $unreadable_manifest;
my $under_test = Bio::ENA::DataSubmission::WEBINCli->new(%$args);
throws_ok {$under_test->run()} 'Bio::ENA::DataSubmission::Exception::CannotReadFile', "dies if manifest is not a readable file";
}
}

remove_tree($temp_input_dir_name, $temp_output_dir_name, $filename, $manifest_filename, $temp_dir_name, $unreadable_manifest);
Expand Down

0 comments on commit f485b29

Please sign in to comment.