I am trying to use a special program called RNAPlot in a QProcess. This program takes an RNA structure file and generates a picture of the structure. The details of this process aren't very pertinent to this problem, it seems to me, but the important part is that it takes an input file and generates an output file (in my case I am trying to have it generate an SVG file).
The place where this QProcess is called is part of a larger project (a QMainWindow calls the class which tries to instantiate the particular QProcess). I can get the QProcess to accept an input file, and it will generate an output file, but it will only write that file to the current working directory. I have tried redirecting its standard output to a new file, but it seems the program (RNAPlot) doesn't use stdout, but opens a new file in the cwd and writes to that. Is there a way to redirect that into a file I specify? Or to have it not write that file but return it to the program so I can write it to a byte array? Or is the fact that the program, RNAPlot, opens its own file and writes to it mean that I can't redirect that like I would if it just wrote to stdout?
This code is for a function in a class that the QMainWindow calls, but I suspect that this is enough context to help with the specific action I would like to happen.
Qt Code:
//create unique file to write structure (picture) to rnaPict->setAutoRemove(false); if(!rnaPict->open()){ qCritical() << "Did not open temp file!"; }else{ qDebug() << "Temp File name: " << rnaPict->fileName(); } rnaPict->close(); rnaPlotCmd = "C:\\Program Files (x86)\\ViennaRNA Package\\RNAplot.exe"; rnaPlotArgs << "-o" << "svg" << filepath; // start RNAplot rnaPlot->setProgram(rnaPlotCmd); rnaPlot->setArguments(rnaPlotArgs); if(!rnaPlot->waitForFinished()){ qCritical() << "RNAPlot failed to finish"; qCritical() << rnaPlot->errorString(); } // nothing is returned and svg_pict ends up empty // (I know because I used debugger to check) // write svg_pict to rnaPictXXXXXX.svg // NOT implemented yet (doesn't matter at this point since svg_pict is empty) }To copy to clipboard, switch view to plain text mode
In short the program I am wanting to use in a QProcess, RNAPlot, always writes its output to the cwd, and I would rather it send its output to a file I specify, or return it so I can put it into a byte array and write it to a file.
Thank you in advance for anyone who is able to help me!
If it's helpful or you're curious about the RNA software I'm using, it's part of ViennaRNA: https://www.tbi.univie.ac.at/RNA/
Also there's a man page for RNAPlot: https://www.tbi.univie.ac.at/RNA/RNAplot.1.html
Bookmarks