#!/usr/bin/env ruby
=begin
------------------------------------------------------------------
  doPlatanus.rb
------------------------------------------------------------------
  for executing platanus for 50 simulated circular read data
------------------------------------------------------------------
  all rights reserved to TOQUE
------------------------------------------------------------------
  started on 02 Mar. 2020
------------------------------------------------------------------
  This script assumes that you have Platanus files in
  /Volumes/comp1/GenomeSeq/Platanus_v1.2.4.  
  After 'chmod +x,' execute the followin commands.
------------------------------------------------------------------
  cd [your_path]/circular20/contigs/
  mkdir platanus
  cd platanus
  ../../rbsCir/doPlatanus.rb
------------------------------------------------------------------
=end

seeds = Array.new
File.open("../../rbsRing/rseeds.txt"){|fh|
  fh.each{|line|
    line.chomp.split(",").each{|rs|
      seeds << rs.to_i
    }
  }
}

seeds.each{|seed|  
  command1 = "../../../software/Platanus_allee_v2.2.2/platanus_allee assemble -o all -f ../../ringReads/r#{seed}/sim90i200c20_?.fq ../../ringReads/r#{seed}/sim90i500c20_?.fq  -t 4 -m 4 2>&1 | tee assemble.log"
  command2 = "../../../software/Platanus_allee_v2.2.2/platanus_allee scaffold -o all -c all_contig.fa -b all_contigBubble.fa -IP1 ../../ringReads/r#{seed}/sim90i200c20_?.fq -IP2 ../../ringReads/r#{seed}/sim90i500c20_?.fq -t 4 2> scaffold.log"
  #  print command; puts
  system(command1)
  system(command2)
  if File.exist?("all_scaffold.fa") then
    command3 = "mv all_scaffold.fa r#{seed}.fa; rm -f all* *.log"
  else
    command3 = "mv all_contig.fa r#{seed}.fa; rm -f all* *.log"
  end
  system(command3)
}  

