pythonbioservices

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


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?


Solution

  • 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.