1

Is it possible to send parameters through a variable to wrapper in python? The wrapper I am using works properly when parameters are provided directly. For example:

ClustalOmegaCommandline(infile='abc.fasta', auto=True, verbose=True, force=True)    

works fine. But passing parameters through a variable, for example,

param = "infile='abc.fasta', auto=True, verbose=True, force=True"
ClustalOmegaCommandline(param)

results in 'Non-zero return code as param is not recognized as an internal or external command'.

Wrapper recognizes param only as a string but cannot recognize them as parameters. Is there a way to get around this?

Manavalan Gajapathy
  • 3,900
  • 2
  • 20
  • 43
  • 3
    I don't know what you mean with wrapper here, but can't you use a `dict` as your variable, and use dict expansion? Thus: `param = {'infile': 'abc.fast', 'auto': True, 'verbose': True, 'force': True}; ClustalOmegaCommandline(**param)`. –  Dec 14 '14 at 09:41
  • 1
    Take a look at this - [link](http://stackoverflow.com/questions/36901/what-does-double-star-and-star-do-for-python-parameters/26365795#26365795) It's a way to send and arbitrary number of arguments to a function. Is this the sort of thing you're looking for? – Joel Dec 14 '14 at 09:42
  • Using dictionary instead of variable solves the problem! Thanks for the suggestion! – Manavalan Gajapathy Dec 14 '14 at 10:14
  • @Evert, It's been a while but if you would post yours as an answer, I will accept it. – Manavalan Gajapathy Feb 11 '15 at 03:20

0 Answers0