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?