1

I am currently running the code for a program called HotNet.

In its simpleRun.py file, there is a place to insert a file path to be run.

parser.add_argument('-mf', '--infmat_file', required=True,
                    help='Path to .mat file containing influence matrix')

My path file is /home/lai/Downloads/influence_matrix_files/hprd_inf_.mat; and I have tried to add it in as such:

parser.add_argument('-mf', '--infmat_file', required=True,
                    help= /home/lai/Downloads/influence_matrix_file/hprd_inf_.mat)

But I get SyntaxError when running the code:

File "simpleRun.py", line 29
    help= ~/home/lai/Downloads/influence_matrix_files/hprd_inf_.mat)
           ^
SyntaxError: invalid syntax

I have also tried to place the path in quotes (as strings ' ') but that isn't processed.

I have tried removing the / however that just returns the following error:

NameError: global name 'home' is not defined

How do I fix this?

1
  • You should access home expansion through os.environ and concatenate the strings. Mar 20, 2014 at 22:31

3 Answers 3

3

Instead of editing the py file, you would simply call the simpleRun.py with the argument:

python simpleRun.py -mf /home/lai/Downloads/influence_matrix_file/hprd_inf_.mat

or

python simpleRun.py --infmat_file=/home/lai/Downloads/influence_matrix_file/hprd_inf_.mat
1
  • +1 Exactly -- the simpleRun already defines '-mf' . The help argument doesn't hold the path, but gives usage help for the mf flag to simpleRun.py .
    – belacqua
    Mar 20, 2014 at 22:07
2

@cyberbills answer is completely correct, but I wanted to add a little more explanation.

You aren't supposed to edit simpleRun.py to add your path -- it's already defined, and the "help" argument is there to give you help when you actually run the simpleRun.py script from the command line.

To put it another way, the help argument doesn't hold the path, but gives usage help for using the -mf flag.

When you use simpleRun.py with "mf", you'll run it as simpleRun.py -mf <file.mat>.

(Note: do a chmod +x on simpleRun.py if you want to run it by typing ./simpleRun.py . Otherwise use python ./simpleRun.py as cyberbill indicates).

All of the parser arguments in simpleRun.py work this way. The text field in the help arg is command line feedback.

You can see it by supplying the --help flag to the command:

$python simpleRun.py --help
usage: simpleRun.py [-h] [-r RUNNAME] -mf INFMAT_FILE -if INFMAT_INDEX_FILE
                    -hf HEAT_FILE [-ms MIN_HEAT_SCORE] [-ccs MIN_CC_SIZE] -pnp
                    PERMUTED_NETWORKS_PATH [-n NUM_PERMUTATIONS]
                    [-o OUTPUT_DIRECTORY] [--parallel] [--no-parallel]
                    [-ef EDGE_FILE] [-nn NETWORK_NAME]

Helper script for simple runs of generalized HotNet2, including automated
parameter selection.

optional arguments:
  -h, --help            show this help message and exit
  -r RUNNAME, --runname RUNNAME
                        Name of run / disease.
  -mf INFMAT_FILE, --infmat_file INFMAT_FILE
                        Path to .mat file containing influence matrix
-1

~/ is the same as /home/lai, so you want to be using ~/Downloads or /home/lai/Downloads.

2
  • Hi Srijay, thank you for your response. I edited it as you suggested; however, I am still receiving the same error message.
    – user260362
    Mar 20, 2014 at 20:10
  • This is a good catch, however the deeper problem is that the OP is using the argument incorrectly when running the code.
    – belacqua
    Mar 20, 2014 at 22:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .