I have the following command to pass into python script.
awk '/^>/{n=split($0,a,"_")} /string/{sum+=a[n]} END{print sum}' filein.fasta
Whatever I try It does a mess (os.system, popen, subprocess.call...) my last attempt is:
string = this variable is a string like "acgactactgtcagtgctgac" provided in a loop
filein = open("filein.fasta")
with open('fileout.txt', 'a+') as outputd:
subprocess.call(['awk', '\'/^>/{n=split($0,a,"_")}', '/' + line + '/{sum+=a[n]}', 'END{print sum}\'', filein], stdout=outputd, shell=True)
in this way, I have no error at this point but it doesn't work properly because it causes a bug after in the script. How can I properly pass this command in python? the quote marks are a sore subject in this situation