0

I am making a pipeline for analizing the quality of a FASTAQ file. Normally, the user would like to take a look at some box plots before deciding to filter or not the sequences. As everything will be running on a server I decided to print everything on the console using the option:

set terminal dumb

The graph appears correctly, but after that the program closes and the next instructions in python are not fulfilled. How can I avoid that my program ends right after plotting?

This is a dummy example of the system calls from python3 where "Please don't close!" is never printed:

import subprocess as sp
proc=sp.Popen(['gnuplot'], shell = True, stdin=sp.PIPE)
proc.stdin.write('set terminal dumb;'.encode('utf-8'))
proc.stdin.write('set style data boxplot;'.encode('utf-8'))
proc.stdin.write('set title "FASTAQ" font "Arial,14";'.encode('utf-8'))
proc.stdin.write('set xtics ("1.0" 1, "1.2" 2, "1.4" 3);'.encode('utf-8'))
proc.stdin.write('plot for [i=1:3] "dummydata.txt" using (i):i notitle;'.encode('utf-8'))
proc.stdin.flush()
#proc.terminate()
print ("Please don't close!")

What dummydata.txt contains is:

# 1.0 1.2 1.4
2.2 2.2 3.06
2.0 2.46 2.93
2.2 2.46 3.06
2.0 2.4 2.8
1.73 2.33 2.8

Correction: One of the instructions proc.stdin.flush() was not correct. I changed it and the problem now is that it does print "Please don't close!" but it does it right before plotting, I would like to be able to see the plot before the text "Please don't close!", is there a way to do this?

  • what is the process `p` that you are terminating? – user8153 May 26 '17 at 23:28
  • Thank you @user8153, I didn't notice the typo. Still it prints "Please don't close" before flushing the graph to the console. I want this to happen in the opposite order. – Libertad Pantoja May 30 '17 at 23:44
  • It sounds like you want the calling python program to wait until gnuplot is finished making the plot. Did you try sending gnuplot the `quit` command, and using `proc.wait()` to wait for gnuplot's termination before proceeding in the python code? – user8153 May 31 '17 at 06:15

0 Answers0