These are chat archives for nextflow-io/nextflow

27th
Jan 2016
Tiffany Delhomme
@tdelhomme
Jan 27 2016 08:27
@pditommaso In fact the problem is on the bash I pass to execute(), I've tried with "mkdir foo" and everything is ok, execute() works without waitFor()...
Paolo Di Tommaso
@pditommaso
Jan 27 2016 08:29
um, I do not think execute is able to parse commands composition, I mean I mean foo | bar etc
I think you will need to manage as bash -c "you commands"
for example:
["bash","-c", "<your command here>"].execute().waitFor()
Tiffany Delhomme
@tdelhomme
Jan 27 2016 08:30
@pditommaso maybe it is my problem yes... also, (outside a process) "mkdir foo".execute() will create a folder foo on current directory, and "echo test > temp.bed" will create a temp.bed on the work directory, but why?
Paolo Di Tommaso
@pditommaso
Jan 27 2016 08:33
the echo test > temp.bed is run by a nextflow process, isn't it?
anyway my tip is that you merge all that code in a nextflow process
you can have a conditional script in a process
Tiffany Delhomme
@tdelhomme
Jan 27 2016 08:36
no it doesn't, i want to run execute() as "first tests"... yes it would be good with conditional processes, i will try this way
is it possible to have the class of the input of a process which depends on user inputs?! I mean here the user can provide either a bed, or a region, or nothing and this will be the input of my process
Paolo Di Tommaso
@pditommaso
Jan 27 2016 08:43
you can have a script that depends on a variable or a user parameter, that it looks what you were trying to do
have a look here
Tiffany Delhomme
@tdelhomme
Jan 27 2016 08:44
ok thanks :smile:
Tiffany Delhomme
@tdelhomme
Jan 27 2016 09:38

could you look at that?

fasta_ref_fai = file( params.fasta_ref+'.fai' )

if(params.region){
    input_region = 'region'
  } else if (params.bed){
    input_region = 'bed'
    bed = file(params.bed)
  } else {
    input_region = 'whole_genome'
  }

process bed {
  output:
  file "*.bed" into outbed

  script:
  if (input_region == 'region')
  """
  echo $params.region | sed -e 's/[:|-]/\t/g' > temp.bed
  """

  else if (input_region == 'bed')
  """
  ln -s $bed temp.bed
  """

  else if (input_region == 'whole_genome')
  """
  cat $fasta_ref_fai | awk '{print \$1"  "0" "\$2 }' > temp.bed
  """
}

process print {
  input:
  file bed from outbed

  echo true
  """
  head $bed
  """
}

everything works, but do you thinks the ln -s is the best way for the case we use the user bed input?

Paolo Di Tommaso
@pditommaso
Jan 27 2016 10:33
to improve you will have to rewrite some parts with groovy/java
for example
if(params.region){
    input_region = helperMethodLikeSed(params.region)
}
else if (params.bed){
    input_region = file(params.bed)
} 
else {
    input_region = helperMethodLikeAwk(fasta_ref_fai)
  }



process print {
  input:
  file bed from input_region

  echo true
  """
  head $bed
  """
}
Tiffany Delhomme
@tdelhomme
Jan 27 2016 10:54
yes ok thanks!