Python Forum
A question about subprocess taking input from command line and returning output!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A question about subprocess taking input from command line and returning output!
#9
I am tryin to think of how to ask an input to be a text file. It can be any .pdb file like 1abc.pdb, 2abc.pdb, 3drt.pdb, etc.
I am working with upgrading the above script to this:
from subprocess import Popen, PIPE

file = raw_input("> ")
read_file = file.format
open_file = open('read_file', 'r+') 

cat = ['cat', 'open_file']
get = ['voronota', 'get-balls-from-atoms-file', '--annotated']
calc = ['voronota', 'calculate-contacts', '--annotated']
que = [
    'voronota', 'query-contacts', '--inter-residue',
    '--match-first', 'R<ARG>',
    '--match-second', 'c<solvent>']
awk = ['awk', '{sum += $3} END {print sum}']
 
cat = Popen(cat, stdout=PIPE)
get = Popen(get, stdin=cat.stdout, stdout=PIPE)
calc = Popen(calc, stdin=get.stdout, stdout=PIPE)
que = Popen(que, stdin=calc.stdout, stdout=PIPE)
awk = Popen(awk, stdin=que.stdout, stdout=PIPE, stderr=PIPE)
out, err = awk.communicate()
print(out)
but am getting this error:
Error:
Traceback (most recent call last): File "voronota_script.py", line 4, in <module> open_file = open('read_file', 'r+') IOError: [Errno 2] No such file or directory: 'read_file'
How is it possible to ask an input to be a txt file (in my case x.pdb where x has 28 different values)?
Reply


Messages In This Thread
RE: A question about subprocess taking input from command line and returning output! - by Aurimas - May-15-2019, 04:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading and storing a line of output from pexpect child eagerissac 1 4,231 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  Receive Input on Same Line? johnywhy 8 704 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  Basic Coding Question: Exit Program Command? RockBlok 3 554 Nov-19-2023, 06:31 PM
Last Post: deanhystad
  problem in using input command akbarza 4 1,106 Oct-19-2023, 03:27 PM
Last Post: popejose
  WHILE LOOP NOT RETURNING USER INPUT AFTER ZerroDivisionError! HELP! ayodele_martins1 7 1,053 Oct-01-2023, 07:36 PM
Last Post: ayodele_martins1
  Using subprocess to execute complex command with many arguments medatib531 5 1,845 Apr-27-2023, 02:23 PM
Last Post: medatib531
  output provide the filename along with the input file processed. arjunaram 1 933 Apr-13-2023, 08:15 PM
Last Post: menator01
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 1,076 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  merge two csv files into output.csv using Subprocess mg24 9 1,757 Dec-11-2022, 09:58 PM
Last Post: Larz60+
  Command line argument issue space issue mg24 5 1,323 Oct-26-2022, 11:05 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020