How to solve "ECitMatch() got multiple values for argument 'bdata'"?

81 Views Asked by At

I am new to use bioservices Python package. Now I am going to use that to retrieve PMIDs for two citations, given the specified information and this is the code I have tried:

from bioservices import EUtils
s = EUtils()
print(s.ECitMatch("pubmed",retmode="xml", bdata="proc+natl+acad+sci+u+s+a|1991|88|3248|mann+bj|Art1|%0Dscience|1987|235|182|palmenberg+ac|Art2|"))

But it occurs an error:

"TypeError: ECitMatch() got multiple values for argument 'bdata'".

Could anyone help me to solve that problem?

2

There are 2 best solutions below

0
On BEST ANSWER

I think the issue is that you have an unnamed argument (pubmed); if you look at the source code, you can see that the first argument should be bdata; if you provide the arguments like you do, it is, however, unclear whether bdata is "pubmed" or the named argument bdata, therefore the error you obtain.

You can reproduce it with this minimal example:

def dummy(a, b): 
   return a, b

dummy(10, a=3)

will return

TypeError: dummy() got multiple values for argument 'a'

If you remove "pubmed", the error disappears, however, the output is still incomplete:

from bioservices import EUtils

s = EUtils()

print(s.ECitMatch("proc+natl+acad+sci+u+s+a|1991|88|3248|mann+bj|Art1|%0Dscience|1987|235|182|palmenberg+ac|Art2|"))

returns

'proc+natl+acad+sci+u+s+a|1991|88|3248|mann+bj|Art1|2014248\n'

so only the first publication is taken into account. You can get the results for both by using the correct carriage return character \r:

print(s.ECitMatch(bdata="proc+natl+acad+sci+u+s+a|1991|88|3248|mann+bj|Art1|\rscience|1987|235|182|palmenberg+ac|Art2|"))

will return

proc+natl+acad+sci+u+s+a|1991|88|3248|mann+bj|Art1|2014248
science|1987|235|182|palmenberg+ac|Art2|3026048

I think you neither have to specify retmod nor the database (pubmed); if you look at the source code I linked above you can see:

query = "ecitmatch.cgi?db=pubmed&retmode=xml"

so seems it always uses pubmed and xml.

0
On

Two issues here: syntaxic and a bug.

The correct syntax is:

    from bioservices import EUtils
    s = EUtils()
    query = "proc+natl+acad+sci+u+s+a|1991|88|3248|mann+bj|Art1|%0Dscience|1987|235|182|palmenberg+ac|Art2|"
    print(s.ECitMatch(query))

Indeed, the underlying service related to ICitMatch has only one database (pubmed) and one format (xml) hence, those 2 parameters are not available : there are hard-coded. Therefore, only one argument is required: your query.

As for the second issue, as pointed above and reported on the bioservices issues page, your query would return only one publication. This was an issue with the special character %0D (in place of a return carriage) not being interpreted corectly by the URL request. This carriage character (either \n, \r or %0d) is now taken into account in the latest version on github or from pypi website if you use version 1.7.5

Thanks to willigot for filling the issue on bioservices page and bringing it to my attention.

disclaimer: i'm the main author of bioservices