getting weird "missing output " error when running a nextflow pipeline - nextflow

For my data analysis pipeline I am using nextflow (which is a workflow management system) and I gave all the required arguments in the main command but I am getting a weird error. Basically in the output section I introduce the output but the error is missing output. I have made 3 files to run the pipeline including:
1- the module containing the main code to run the tool (ASEReadCounter) and named ASEReadCounter.nf :
process ASEReadCounter {
input:
file vcf_file
file bam_file
path(genome_fasta)
output:
file "${vcf_file}.ASE.csv"
script:
"""
gatk ASEReadCounter \\
-R ${params.genome} \\
-V ${params.vcf_infile} \\
-O ${params.vcf_infile}.txt \\
-I ${params.bam_infile}
"""
}
2- the main file which is used to run the pipeline named main.nf :
#!/usr/bin/env nextflow
nextflow.preview.dsl=2
include ASEReadCounter from './modules/ASEReadCounter.nf'
genome_ch = Channel.fromPath(params.genome)
vcf_file_ch=Channel.fromPath(params.vcf_infile)
bam_infile_ch=Channel.fromPath(params.bam_infile)
workflow {
count_ch=ASEReadCounter(genome_ch, vcf_file_ch, bam_infile_ch)
}
3- config file which is named nextflow.config :
params {
genome = '/hpc/hg38_genome/GRCh38.p13.genome.fa'
vcf_infile = '/hpc/test_data/test/test.vcf.gz'
bam_infile = ‘/hpc/test_data/test/test.sorted.bam'
}
process {
shell = ['/bin/bash', '-euo', 'pipefail']
withName: ASEReadCounter {
container = 'broadinstitute/gatk:latest'
}
}
singularity {
enabled = true
runOptions = '-B /hpc:/hpc -B $TMPDIR:$TMPDIR'
autoMounts = true
cacheDir = '/hpc/diaggen/software/singularity_cache'
}
here is the command I use to run the whole pipeline:
nextflow run -ansi-log false main.nf
Here is the error I am getting:
Error executing process > 'ASEReadCounter (1)'
Caused by:
Missing output file(s) `GRCh38.p13.genome.fa.ASE.csv` expected by process `ASEReadCounter (1)`
Command executed:
gatk ASEReadCounter -R /hpc/hg38_genome/GRCh38.p13.genome.fa \
-V /hpc/test_data/test/test.vcf.gz \
-O /hpc/test_data/test/test.vcf.gz.txt \
-I /hpc/test_data/test/test.sorted.bam
Do you know how I can fix the error?

Your ASEReadCounter process expects a file with the pattern ${vcf_file}.ASE.csv as output, as defined at:
output:
file "${vcf_file}.ASE.csv"
I assume the line -O ${params.vcf_infile}.txt makes it so your gatk ASEReadCounter command writes its output to a file with the pattern $params.vcf_infile}.txt. The expected output and the actual output filenames don't match and nextflow throws an error because it doesn't want to contine since a downstream process might need the output file. You can fix it by matching the expected output and actual output patterns,

Related

Yocto include cmake project with custom steps

I am trying to include this simple cmake-based project to my image: https://github.com/MatrixOrbital/HTT-Utility
The steps to build in Linux are:
mkdir build
cd build
cmake ..
make
I am trying to reproduce these steps within my Yocto recipe. The generated binary (./build/htt_util) should be installed in /usr/bin.
So far with the help of devtool and some manual tuning I ended up with this recipe:
LICENSE = "MIT & Unknown"
LIC_FILES_CHKSUM = "file://LICENSE;md5=ff75ee274f4c77abeee3db089083fec7 \
file://hidapi/LICENSE.txt;md5=7c3949a631240cb6c31c50f3eb696077"
SRC_URI = "git://github.com/MatrixOrbital/HTT-Utility.git;protocol=https"
SRC_URI += "file://0001-Adding-ctype.patch;"
PATCHTOOL = "git"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "2045d5eacc67b89a02dafe41edfd032179333aee"
S = "${WORKDIR}/git"
inherit cmake
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = ""
DEPENDS += "udev"
What should I add to my recipe to achieve the goal of generating a binary and installing into /usr/bin?
I have been trying to play with:
do_configure() {
...
}
do_compile() {
...
}
do_install() {
...
}
But so far I did not manage to do anything useful.
Any help would be appreciated.
do_install() {
install -m 0644 mybinary ${D}${bindir}
}
FILES_${PN} = " \
${bindir} \
"

failing to pass argument to puppet apply with facts

I am trying to pass a facter argument to puppet apply. Here's what I tried:
export FACTER_command="start"
puppet apply site.pp $FACTER_command
and in my code I have:
exec { 'some_exec':
command => '/bin/bash -c "/some/path/to/scripts.sh -t some_arg $::command"',
...
I get this message error:
Error: '/bin/bash -c "/some/path/to/scripts.sh -t some_arg $::command"' returned 1 instead of one of [0]
Error: /Stage[main]/Standard/Exec[some_exec]/returns: change from 'notrun' to ['0'] failed: '/some/path/to/scripts.sh -t some_arg $::command"' returned 1 instead of one of [0]
Does anyone have any idea about this?
UPDATE
class standard{
$param_test="/some/path/to/scripts.sh -t some_arg ${::command}"
file{'kick_servers':
ensure => 'file',
path => '/some/path/to/scripts.sh',
owner => 'some_user,
group => 'some_user',
mode => '0755',
notify => Exec['some_exec']
}
exec { 'some_exec':
command => '/bin/bash -c ${param_test}',
cwd => "$home_user_dir",
timeout => 1800
}
}
node default {
include standard
}
And I get this error
Error: '/bin/bash -c $param_test' returned 2 instead of one of [0]
Error: /Stage[main]/Standard/Exec[some_exec]/returns: change from 'notrun' to ['0'] failed: '/bin/bash -c $param_test' returned 2 instead of one of [0]
Yes. You have at least two issues you need to fix there:
1/
The immediate cause of your problem is you have enclosed $::command inside single quotes, telling Puppet that you mean the literal string $::command, when you actually want the value of the fact there.
2/
You should not be passing $FACTER_command as an argument to puppet apply; you only need to export it as an environment variable (which you already did).
So:
Change puppet apply to:
puppet apply site.pp
Change your exec to:
exec { 'some_exec':
command => "/bin/bash -c '/some/path/to/scripts.sh -t some_arg ${::command}'",
...
}

Creating a Perl 6 module containing Perl 5 utility scripts in bin/

Perl 6 script in a Perl 5 module distribution
I can include a Perl 6 script in a Perl 5 module distribution:
# Create a new module
dzil new My::Dist
cd My-Dist/
# Add necessary boilerplate
echo '# ABSTRACT: boilerplate' >> lib/My/Dist.pm
# Create Perl 6 script in bin directory
mkdir bin
echo '#!/usr/bin/env perl6' > bin/hello.p6
echo 'put "Hello world!";' >> bin/hello.p6
# Install module
dzil install
# Test script
hello.p6
# Hello world!
# See that it is actually installed
which hello.p6
# ~/perl5/perlbrew/perls/perl-5.20.1/bin/hello.p6
Perl 5 script in a Perl 6 module distribution
However, I'm having a hard time including Perl 5 scripts in a Perl 6 distribution.
In the module directory is a META6.json file and a subdirectory called bin. In bin is a Perl 5 file called hello.pl.
zef install . runs without error in the top directory. But when trying to run hello.pl, I get an error. Come to find out, a Perl 6 wrapper script had been installed for hello.pl and that is what is giving me the error. If I run the original hello.pl directly, it works fine.
META6.json
{
"perl" : "6.c",
"name" : "TESTING1234",
"license" : "Artistic-2.0",
"version" : "0.0.2",
"auth" : "github:author",
"authors" : ["First Last"],
"description" : "TESTING module creation",
"provides" : {
},
"depends" : [ ],
"test-depends" : [ "Test", "Test::META" ]
}
bin/hello.pl
#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
say 'Hello world!';
This installs without error, but when I try to run hello.pl, I get the following error:
===SORRY!===
Could not find Perl5 at line 2 in:
/home/username/.perl6
/path/to/perl6/rakudo-star-2017.07/install/share/perl6/site
/path/to/perl6/rakudo-star-2017.07/install/share/perl6/vendor
/path/to/perl6/rakudo-star-2017.07/install/share/perl6
CompUnit::Repository::AbsolutePath<64730416>
CompUnit::Repository::NQP<43359856>
CompUnit::Repository::Perl5<43359896>
which hello.pl from the command line indicated that it was installed in /path/to/perl6/rakudo-star-2017.07/install/share/perl6/site/bin/hello.pl. That file is actually the following code:
/path/to/perl6/rakudo-star-2017.07/install/share/perl6/site/bin/hello.pl
#!/usr/bin/env perl6
sub MAIN(:$name is copy, :$auth, :$ver, *#, *%) {
CompUnit::RepositoryRegistry.run-script("hello.pl", :dist-name<TESTING1234>, :$name, :$auth, :$ver);
}
I filed a Rakudo bug report (https://rt.perl.org/Ticket/Display.html?id=131911), but I'm not totally convinced that there isn't a simple work around.
As an example, I created a simple cat replacement in Perl 5 and created a Perl 6 module that "wrapped" around it (see the GitHub repository for it if you'd like to download the code and try it yourself).
Below are copies of the relevant files. After creating these files, running zef install . installs fine with my Rakudo Star 2017.07 installation. This installs a run_cat executable in your Rakudo bin directory.
It seemed like the secret was to make a Perl 6 module file to wrap the Perl 5 script and a corresponding Perl 6 script to use the Perl 6 module.
Perl 5 script
resources/scripts/cat.pl
#!/bin/env perl
use v5.10;
use strict;
use warnings;
while(<>) {
print;
}
Wrapper scripts
module: lib/catenate.pm6
unit module catenate;
sub cat ($filename) is export {
run('perl',%?RESOURCES<scripts/cat.pl>,$filename);
}
executable: bin/run_cat
#!/bin/env perl6
use catenate;
sub MAIN ($filename) {
cat($filename);
}
Boilerplate and tests
META6.json`
{
"perl" : "6.c",
"name" : "cat",
"license" : "Artistic-2.0",
"version" : "0.0.9",
"auth" : "github:author",
"authors" : ["First Last"],
"description" : "file catenation utility",
"provides" : { "catenate" : "lib/catenate.pm6" },
"test-depends" : [ "Test", "Test::META" ],
"resources" : [ "scripts/cat.pl" ]
}
t/cat.t
#!/bin/env perl6
use Test;
constant GREETING = 'Hello world!';
my $filename = 'test.txt';
spurt($filename, GREETING);
my $p5 = qqx{ resources/scripts/cat.pl $filename };
my $p6 = qqx{ bin/run_cat $filename };
is $p6, $p5, 'wrapped script gives same result as original';
is $p6, GREETING, "output is '{GREETING}' as expected";
unlink $filename;
done-testing;
Thanks #moritz and #ugexe for getting me pointed in the right direction!

How do I loop through files in npm in a way that works on Windows & linux?

I'm trying to run a single command (jshint), on multiple files. My package.json contains
"lint": "jshint *.js **/*.js"
However this fails miserable on Windows. On Windows the syntax to iterate on multiple files is
for %%f in (*.in) do (
echo %%~nf
)
Is there a simple, platform-agnostic way to run a single npm script (e.g. jshint) on multiple files?
(I'm interested in the general solution. There's a references here to using node-jslint instead of jshint, which does support multiple files ... but IMO jshint >> jslint).
I'm also not aware of a platform agnostic way to loop in the shell.
However, a platform agnostic solution to running a single npm-script on multiple files with jshint, as per your example, is to:
Utilize cli-glob to find the .js files.
Pipe the results/paths from the globbing pattern to a custom utility node script.
Then within the node script:
Read the paths piped to stdin using nodes readline module.
Create an Array of each path and subsequently convert that to a String.
Run the jshint executable, (including the String of all paths), using nodes child_process.exec() module.
Whilst this solution is not particularly "simple", the following gists demonstrate this process:
npm-script
"scripts": {
"jshint": "glob \"src/js/**/*.js\" | node .scripts/jshint.js"
},
Note cli-glob, (added to package.json), obtains the paths and pipes them to jshint.js.
jshint.js
#!/usr/bin/env node
'use strict';
var path = require('path');
var readline = require('readline');
var exec = require('child_process').exec;
var rl = readline.createInterface({
input: process.stdin,
output: null,
terminal: false
});
// Normalise path to local jshint executable.
var jshintExec = ['.', 'node_modules', '.bin', 'jshint '].join(path.sep);
var paths = [];
function jshint(paths) {
var command = [jshintExec, paths].join('');
exec(command, function(error, stdout, stderr) {
if (stdout) {
console.log(stdout);
}
if (stderr) {
console.log(stderr);
}
});
}
rl.on('line', function(srcPath) {
paths.push(srcPath);
});
rl.on('close', function() {
jshint(paths.join(' '));
});
Note
Line 16 reading:
var jshintExec = ['.', 'node_modules', '.bin', 'jshint '].join(path.sep);
The script assumes jshint has been installed locally and added to the "devDependencies": {} section of the package.json. I.e. Its pointing to the local jhint executable found in the node_modules/.bin folder and not the globally installed one.
If your preference is to run the globally installed jshint then change line 16 to:
var jshintExec = 'jshint ';
Personally, having it installed locally is the preferred option IMHO for this scenario!
Multiple globbing patterns
Your example provided includes multiple glob patterns.
"lint": "jshint *.js **/*.js"
One limitation of cli-glob is that it doesn't accept multiple glob patterns. So one workaround is to do something like this:
"scripts": {
"jshint": "npm run jshint-a && npm run jshint-b",
"jshint-a": "glob \"*.js\" | node .scripts/jshint.js",
"jshint-b": "glob \"**/*.js\" | node .scripts/jshint.js"
},
Yeah, not particularly terse - but works!
To the best of my knowledge, you can't loop in the shell in a cross-platform way.
However, you can use https://www.npmjs.com/package/catw and do something like this:
catw "**/*.js" | jshint -
catw will expand the glob(s) itself without relying on the shell and write the files to stdout. jshint - will read from stdin. The pipe (|) works cross-platform.

ImageMagick or GhostScript: convert a multi-page TIFF to a multi-page PDF

I need to convert a multi-page TIFF to a multi-page PDF. I have access to ImageMagick and GhostScript (in *nix environment). How do I do this? Thanks.
UPDATE:
It turns out that my test file was wrong (it didn't have multiple pages), which made me think my command was wrong. This seems to work for me: convert input.tif output.pdf
convert multipage.tiff -density 300x300 -compress jpeg multipage.pdf
This should work, though there can be some issues.
Use a tool called tiff2ps from the tool set provided by libtiff:
http://www.libtiff.org/tools.html
Once you have the tiff in ps format, you can call ps2pdf to convert to pdf, which is part of the ghostscript package in most linux distributions.
Use following code to generate multi page pdf from multi page tiff file:
<?php
$images = new Imagick($pathToYourFile);
foreach($images as $i=>$image) {
$image->setImageFormat("pdf");
$images->addImage( $image );
}
$images->writeImages($yourFileName.'.pdf', true);
?>
I had a similar situation of converting a multipage TIFF file. but in my case the resulting extension was JPG thumbnail. However, I believe that this following code will run for converting TIFF to PDF. http://sourcecodemania.com/how-to-convert-text-to-speech-with-php/
<?php
try
{
// Saving every page of a TIFF separately as a JPG thumbnail
$images = new Imagick("testing.tif");
foreach($images as $i=>$image) {
// Providing 0 forces thumbnail Image to maintain aspect ratio
$image->thumbnailImage(768,0);
$image->writeImage("page".$i.".jpg");
echo "<img src='page$i.jpg' alt='images' ></img>";
}
$images->clear();
}
catch(Exception $e)
{
echo $e->getMessage();
}
?>
Comments are welcome
http://www.sourcecodemania.com
#!/bin/bash
# scanadf frontend
# kdialog info at http://techbase.kde.org/Development/Tutorials/Shell_Scripting_with_KDE_Dialogs#Menu_and_Selection_Dialogs
# i/o redirection at http://tldp.org/LDP/abs/html/io-redirection.html
# variable to file i/o at http://www.linuxquestions.org/questions/programming-9/bash-script-%96-reading-and-writing variables-to-a-separate-file-365158/
#
#rev. 1.2 03.02.12
#
#NOTE: TO RUN THIS SCRIPT YOU WILL NEED TO CREATE THE DIRECTORIES REFERRED TO IN THE SCRIPT.
#THE ANSWER TO THE QUESTION IS THE TWO-PASS COMMANDS BELOW "convert" and "gs"
#THE CONVERT COMMAND COMBINES ALL THE TIFFS IN THE DIRECTORY INTO A SINGLE PDF
#THE GS (GHOSTSCRIPT) COMMAND RESIZES TO 8.5X11 AND COMPRESSES
#
#
#THIS IS A KDIALOG SCRIPT AND WILL ONLY RUN IN KDE. KDIALOG COMMANDS COULD BE REPLACED BY DIALOG COMMANDS
#ALTERNATIVELY, THE KDIALOG COMMANDS COULD BE REPLACED BY COMMAND LINE COMMANDS AND RUN IN A TERMINAL.
#
yn1=1
cd ~/.getscan/
. config
while [ $yn1 = 1 ];
do
cd ~/.getscan/tmp/
kdialog --title "scanner activated" --passivepopup "scanner warming up"
if [ $scnr = 2 ];then
scanadf --mode $clr --resolution $res -y 279 --source 'Automatic Document Feeder(left aligned,Duplex)' 2>test.txt
else
scanadf --mode $clr --resolution $res -y 279 2>test.txt
fi
err1=$(cat test.txt)
rm test.txt
#
#scanner error trap
#
if [ $? = 1 ];then
kdialog --title "scanner error" --msgbox "$err1"
else
#
#don't want to accidentally create in tmp folder.
#"label" kdialog option didn't work
#
kdialog --title "scanner info" --passivepopup "$err1" 5
cd ~/downloads/transfer
name=`kdialog --getsavefilename :newscan.pdf "*.pdf"`
cd ~/.getscan/tmp/
# convert * $name
convert * tmp/temp.pdf
gs -o $name -sDEVICE=pdfwrite -dPDFFitPage -r300x300 -g2550x3300 tmp/temp.pdf
rm *
rm tmp/*
okular $name
fi
yn1=`kdialog --title "continue?" --radiolist "Select:" 1 "scan another document?" on 2 "stop" off 3 "change settings" off --geometry 150x100+300+300 `
if [ $yn1 = 2 ];then
yn1="y"
fi
if [ $yn1 = 3 ];then
cd ~/.getscan/
. config
if [ $scnr = 2 ];then
scnr="ADF-Duplex"
fi
res1=`kdialog --title "scanner resolution" --radiolist "Select Resolution:" 1 "100" off 2 "200" off 3 "300" on 4 "400" off 5 "500" off 6 "600"`
if [ $res1 = 3 ];then
res1=300
fi
echo res=$res1 > config
clr1=`kdialog --title "color" --radiolist "Select Resolution:" 1 "black & white" on 2 "24bit color" off`
if [ $clr1 = 1 ];then
clr1=black
fi
if [ $clr1 = 2 ];then
clr1="'24bit color'"
fi
echo clr=$clr1 >> config
scnr1=`kdialog --title "mode" --radiolist "Select Resolution:" 1 "ADF" on 2 "ADF duplex" off`
if [ $scnr1 = 1 ];then
scnr1="1"
fi
if [ $scnr1 = 2 ];then
scnr1="2"
fi
echo scnr=$scnr1 >> config
. config
yn1=1
fi
done
exit 0