def mapDrugPairs(list, xref):
    """ map drug pairs to PDDI dicts. Each key points to a list of PDDIs that share a drug pair """
    pddiDictL = []
    for p in list:
        d1 = p["drug1"]
        d2 = p["drug2"]

        if xref.has_key(d1) and xref.has_key(d2):
            pddi = getPDDIDict()
            (pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"],
             pddi["severity"], pddi["uri"], pddi["label"],
             pddi["source"]) = (xref[d1]["drugname"],
                                "http://bio2rdf.org/drugbank:" +
                                str(xref[d1]["mappedIDs"][0]),
                                xref[d2]["drugname"],
                                "http://bio2rdf.org/drugbank:" +
                                str(xref[d2]["mappedIDs"][0]), p["severity"],
                                p["uri"], p["label"], "NDF-RT")

            print "object: %s: %s-- precipitant:%s : %s" % (
                pddi["object"], pddi["drug1"], pddi["precipitant"],
                pddi["drug2"])

            # return the dictionary entry
            pddiDictL.append(pddi)

    return pddiDictL
def mapDrugPairs(list, xref):
    """ map drug pairs to PDDI dicts. Each key points to a list of PDDIs that share a drug pair """
    pddiDictL = []
    for p in list:  
        d1 = p["drug1"]
        d2 = p["drug2"] 
        
        if xref.has_key(d1) and xref.has_key(d2):
            pddi = getPDDIDict()        
            (
             pddi["object"],
             pddi["drug1"],
             pddi["precipitant"],
             pddi["drug2"],
             pddi["severity"],
             pddi["uri"],
             pddi["label"], 
             pddi["source"]        
            )=( 
                xref[d1]["drugname"],
                "http://bio2rdf.org/drugbank:" + str(xref[d1]["mappedIDs"][0]), 
                xref[d2]["drugname"],
                "http://bio2rdf.org/drugbank:" + str(xref[d2]["mappedIDs"][0]),  
                p["severity"],
                p["uri"], 
                p["label"],
                "NDF-RT"
              )
           
            print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
           
            # return the dictionary entry
            pddiDictL.append(pddi)
                     
    return pddiDictL     
def WorldVista_Pickle_Generator(datafile):
    # open the World-Vista data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           World-Vista PDDI.
   
    pddiDictL = []

    f = open(datafile, 'r')
    
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug_1") != -1: # skips header and stops at EOF
               l = f.readline()
        
        
        elts = l.strip("\n").split("$")
        pddi = getPDDIDict()
        
        (
         pddi["object"],
         pddi["drug1"],
         pddi["precipitant"],
         pddi["drug2"],
         pddi["severity"],
         pddi["homepage"],
         pddi["ddiPkMechanism"],
         pddi["label"],
         pddi["source"]
        )=(
            elts[0], 
            "http://bio2rdf.org/drugbank:" + str(elts[1]), 
            elts[2], 
            "http://bio2rdf.org/drugbank:" +str(elts[3]),
            elts[4],
            elts[5],
            elts[6],
            elts[7],
            "World-Vista"
          )
           
        #print "ID: %s - object: %s: %s-- precipitant:%s : %s" % (elts[0],pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
        print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
                    
        # return the dictionary entry
        pddiDictL.append(pddi)
                     
    return pddiDictL       
def NLMCorpus_Pickle_Generator(datafile):
    # open the NLMCorpus_ data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           NLMCorpus_Mapped PDDI.

    pddiDictL = []

    f = open(datafile, "r")

    while 1:
        if not f:
            f.close()
            raise StopIteration

        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug_1") != -1:  # skips header and stops at EOF
                l = f.readline()

        elts = l.strip("\n").split("$")
        pddi = getPDDIDict()

        (
            pddi["object"],
            pddi["drug1"],
            pddi["precipitant"],
            pddi["drug2"],
            pddi["ddiType"],
            pddi["evidenceStatement"],
            pddi["source"],
        ) = (
            elts[0],
            "http://bio2rdf.org/drugbank:" + str(elts[2]),
            elts[3],
            "http://bio2rdf.org/drugbank:" + str(elts[5]),
            elts[6],
            elts[7],
            "NLM-Corpus",
        )

        print "object: %s: %s-- precipitant:%s : %s" % (
            pddi["object"],
            pddi["drug1"],
            pddi["precipitant"],
            pddi["drug2"],
        )

        # return the dictionary entry
        pddiDictL.append(pddi)

    return pddiDictL
def OSCAR_Pickle_Generator():
    # open the OSCAR data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           OSCAR  PDDI.
   
    pddiDictL = []
    f = open(OSCAR_DATA, 'r')
    
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug_1") != -1: # skips header and stops at EOF
               l = f.readline()
        
        elts = l.strip("\n").split("$")
        pddi = getPDDIDict()        
        (
         pddi["object"],
         pddi["drug1"],
         pddi["precipitant"],
         pddi["drug2"], 
         pddi["effectConcept"], 
         pddi["severity"], 
         pddi["evidence"], 
         pddi["evidenceStatement"], 
         pddi["source"]
        )=(
            elts[1], 
            elts[3],  
            elts[5],
            elts[7], 
            elts[8],
            elts[9],
            elts[10],
            elts[11],
            "OSCAR"
          ) 
            
        print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
              
        # return the dictionary entry
        pddiDictL.append(pddi)
                     
    return pddiDictL       
def PKCorpus_Pickle_Generator(datafile):
    # open the PKCorpus_ data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           PKCorpus_Mapped PDDI.
   
    pddiDictL = []
    f = open(datafile, 'r')
    
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug_1") != -1: # skips header and stops at EOF
               l = f.readline()
           
       
        elts = l.strip("\n").split("$")
        pddi = getPDDIDict()        
        (
         pddi["object"],
         pddi["drug1"],
         pddi["whoAnnotated"], 
         pddi["precipitant"],
         pddi["drug2"],
         #pddi["ddiPkEffect"],
         pddi["evidenceStatement"],
         pddi["source"]
        )=(
            elts[0], 
            "http://bio2rdf.org/drugbank:" + str(elts[3]), 
            elts[6],
            elts[4], 
            "http://bio2rdf.org/drugbank:" +str(elts[7]),
            #elts[10],
            elts[11],  
            "PK-Corpus"
          )  
        print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
              
        # return the dictionary entry
        pddiDictL.append(pddi)
                     
    return pddiDictL       
def hiv_DDI_Pickle_Generator():
    # open the HIV-drug-interactions data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           HIV-drug-interactions .
   
    pddiDictL = []
    f = open(HIV_DDI_DATA, 'r')
    
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug 1") != -1: # skips header and stops at EOF
               l = f.readline()
     
              
            elts = l.strip("\n").split("\t")
            pddi = getPDDIDict()
            (pddi["object"], 
             pddi["drug1"],
             pddi["precipitant"], 
             pddi["drug2"],
             pddi["evidenceStatement"], 
             pddi["label"],
             pddi["source"]
             ) = (
                  elts[0], 
                  "http://bio2rdf.org/drugbank:" + str(elts[1]), 
                  elts[2], 
                  "http://bio2rdf.org/drugbank:" + str(elts[3]), 
                  elts[4], 
                  elts[5],  
                  "HIV"
                  )
            
            print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
            #print "effectConcept: %s:-- ddiPkMechanism: %s" % (pddi["effectConcept"],pddi["ddiPkMechanism"] )
               
            # return the dictionary entry
            pddiDictL.append(pddi) 
         
    return pddiDictL       
def DDICorpus2011_Pickle_Generator(datafile):
    # open the DDI-Corpus2011 data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           DDI-Corpus2011 PDDI.
   
    pddiDictL = []

    f = open(datafile, 'r')
    
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("object") != -1: # skips header and stops at EOF
               l = f.readline()
         
            elts = l.strip("\n").split("$")
            pddi = getPDDIDict()
            (pddi["object"], 
             pddi["drug1"],
             pddi["precipitant"], 
             pddi["drug2"], 
             pddi["evidenceStatement"], 
             pddi["source"]
             ) = (
             elts[0], 
             "http://bio2rdf.org/drugbank:" + str(elts[1]), 
             elts[2], 
             "http://bio2rdf.org/drugbank:" + str(elts[3]), 
             elts[4], 
             "DDI-Corpus-2011"
             )
            
            print "object: %s: %s-- precipitant:%s : %s " % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
                       
            #print "ID: %s - object: %s: %s-- precipitant:%s : %s -evidence: %s " % (elts[0],pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"], pddi["evidenceStatement"])
              
            # return the dictionary entry
            pddiDictL.append(pddi)
                     
    return pddiDictL       
def Drugbank4_Pickle_Generator():
    # open the load-Drugbank4-DDIs data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           a PDDI.
   
    pddiDictL = []
    
    f = open(Drugbank4_DATA, 'r')
    
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("object_drugbank") != -1: # skips header and stops at EOF
               l = f.readline() 
        
        elts = l.strip("\n").split("$")
        #elts = l.strip("\n").split(",")
          
        pddi = getPDDIDict()             
        (pddi["object"], 
         pddi["drug1"],
         pddi["precipitant"], 
         pddi["drug2"], 
         pddi["source"]
         ) = (
              elts[1], 
              "http://bio2rdf.org/drugbank:" + str(elts[0]), 
              elts[3], 
              "http://bio2rdf.org/drugbank:" + str(elts[2]), 
              "Drugbank"
              )
        #print "object: %s -- precipitant:%s " %(pddi["object"],pddi["precipitant"])
        print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
             
        # return the dictionary entry
        pddiDictL.append(pddi)

         
    return pddiDictL       
def Drugbank_Pickle_Generator():
    # open the load-Drugbank4-DDIs data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           a PDDI.
  
    pddiDictL = []    
    f = open(Drugbank_DATA, 'r')    
    
      
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("object_drugbank") != -1: # skips header and stops at EOF
               l = f.readline() 
        
        elts = l.strip("\n").split("$")
          
        pddi = getPDDIDict()             
        (pddi["object"], 
         pddi["drug1"],
         pddi["precipitant"], 
         pddi["drug2"], 
         pddi["label"], 
         pddi["source"]
         ) = (
              elts[1], 
              "http://bio2rdf.org/drugbank:" + str(elts[0]), 
              elts[3],               
              "http://bio2rdf.org/drugbank:" + str(elts[2]), 
              elts[4], 
              "Drugbank"
              )

        #print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"]) 
             
        # return the dictionary entry
        pddiDictL.append(pddi)
             
    return pddiDictL       
def frenchDB_Pickle_Generator():
    # open the FRENCHDB data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           FRENCHDB PDDI.
    # Dataset contains fields:"mol2"(drug2),"mol1"(drug1),"prota2"(class2),"prota1"(class1),
    #                         "description_interaction","mecanisme","niveau"(severity level),
    #                         "DB1"(drug1 Drugbank ID),"DB2"(drug2 Drugbank ID)

    pddiDictL = []
    f = open(FRENCHDB_DATA, 'rb')
    reader = csv.reader(f, delimiter='\t', quotechar='|')

    while 1:
        if not f:
            f.close()
            raise StopIteration

        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("mol1") != -1:  # skips header and stops at EOF
                l = f.readline()

            elts = l.strip("\n").split("\t")
            pddi = getPDDIDict()
            (pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"],
             pddi["label"], pddi["severity"],
             pddi["source"]) = (elts[0].strip("\""),
                                "http://bio2rdf.org/drugbank:" +
                                str(elts[8]).strip("\""), elts[1].strip("\""),
                                "http://bio2rdf.org/drugbank:" +
                                str(elts[7]).strip("\""), elts[4].strip("\""),
                                elts[6].strip("\""), "FrenchDB")

            print "object: %s: %s-- precipitant:%s : %s" % (
                pddi["object"], pddi["drug1"], pddi["precipitant"],
                pddi["drug2"])
            #print "effectConcept: %s:-- ddiPkMechanism: %s" % (pddi["effectConcept"],pddi["ddiPkMechanism"] )

            # return the dictionary entry
            pddiDictL.append(pddi)

    return pddiDictL
def ONC_NonInteruptive_Pickle_Generator():
    # open the ONCHighPriority data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           ONCHighPriority  PDDI.
   
    pddiDictL = []

    f = open(ONCNonInteruptive_DATA, 'r')
    
    while 1 :
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug_1") != -1: # skips header and stops at EOF
               l = f.readline()
                  
        elts = l.strip("\n").split("$")
        pddi = getPDDIDict()        
        (
         pddi["object"],
         pddi["drug1"],
         pddi["precipitant"],
         pddi["drug2"], 
         pddi["source"]
        )=(
            elts[0], 
            "http://bio2rdf.org/drugbank:" + str(elts[1]), 
            elts[2],
            "http://bio2rdf.org/drugbank:" + str(elts[3]), 
            "ONC-NonInteruptive"
          )           
            
        print "object: %s: %s-- precipitant:%s : %s" % (pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
              
        # return the dictionary entry
        pddiDictL.append(pddi)
                     
    return pddiDictL       
Ejemplo n.º 13
0
def DDICorpus2011_Pickle_Generator(datafile):
    # open the DDI-Corpus2011 data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           DDI-Corpus2011 PDDI.

    pddiDictL = []

    f = open(datafile, 'r')

    while 1:
        if not f:
            f.close()
            raise StopIteration

        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("object") != -1:  # skips header and stops at EOF
                l = f.readline()

            elts = l.strip("\n").split("$")
            pddi = getPDDIDict()
            (pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"],
             pddi["evidenceStatement"],
             pddi["source"]) = (elts[0], "http://bio2rdf.org/drugbank:" +
                                str(elts[1]), elts[2],
                                "http://bio2rdf.org/drugbank:" + str(elts[3]),
                                elts[4], "DDI-Corpus-2011")

            print "object: %s: %s-- precipitant:%s : %s " % (
                pddi["object"], pddi["drug1"], pddi["precipitant"],
                pddi["drug2"])

            #print "ID: %s - object: %s: %s-- precipitant:%s : %s -evidence: %s " % (elts[0],pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"], pddi["evidenceStatement"])

            # return the dictionary entry
            pddiDictL.append(pddi)

    return pddiDictL
def WorldVista_Pickle_Generator(datafile):
    # open the World-Vista data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           World-Vista PDDI.

    pddiDictL = []

    f = open(datafile, 'r')

    while 1:
        if not f:
            f.close()
            raise StopIteration

        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug_1") != -1:  # skips header and stops at EOF
                l = f.readline()

        elts = l.strip("\n").split("$")
        pddi = getPDDIDict()

        (pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"],
         pddi["severity"], pddi["homepage"], pddi["ddiPkMechanism"],
         pddi["label"],
         pddi["source"]) = (elts[0], "http://bio2rdf.org/drugbank:" +
                            str(elts[1]), elts[2],
                            "http://bio2rdf.org/drugbank:" + str(elts[3]),
                            elts[4], elts[5], elts[6], elts[7], "World-Vista")

        #print "ID: %s - object: %s: %s-- precipitant:%s : %s" % (elts[0],pddi["object"],pddi["drug1"],pddi["precipitant"], pddi["drug2"])
        print "object: %s: %s-- precipitant:%s : %s" % (
            pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"])

        # return the dictionary entry
        pddiDictL.append(pddi)

    return pddiDictL
Ejemplo n.º 15
0
def hiv_DDI_Pickle_Generator():
    # open the HIV-drug-interactions data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           HIV-drug-interactions .

    pddiDictL = []
    f = open(HIV_DDI_DATA, 'r')

    while 1:
        if not f:
            f.close()
            raise StopIteration

        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug 1") != -1:  # skips header and stops at EOF
                l = f.readline()

            elts = l.strip("\n").split("\t")
            pddi = getPDDIDict()
            (pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"],
             pddi["evidenceStatement"], pddi["label"],
             pddi["source"]) = (elts[0], "http://bio2rdf.org/drugbank:" +
                                str(elts[1]), elts[2],
                                "http://bio2rdf.org/drugbank:" + str(elts[3]),
                                elts[4], elts[5], "HIV")

            print "object: %s: %s-- precipitant:%s : %s" % (
                pddi["object"], pddi["drug1"], pddi["precipitant"],
                pddi["drug2"])
            #print "effectConcept: %s:-- ddiPkMechanism: %s" % (pddi["effectConcept"],pddi["ddiPkMechanism"] )

            # return the dictionary entry
            pddiDictL.append(pddi)

    return pddiDictL
def twosides_f_generator():
    # open the twosides data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           twosides PDDI.
    f = open(TWOSIDES_DATA, 'r')
    
    while 1:
        if not f:
            f.close()
            raise StopIteration
        
        l = f.readline()
        while l.find("CID") == -1: # skips header and stops at EOF
            l = f.readline()
            if l == "":
                f.close()
                raise StopIteration

        elts = l.strip("\n").split("\t")
        pddi = getPDDIDict()
        (pddi["drug1"], 
         pddi["drug2"], 
         #pddi["label"], 
         pddi["effectConcept"], 
         pddi["certainty"], 
         pddi["source"]
         ) = (
              elts[0], 
              elts[1], 
              #elts[4], 
              elts[5], 
              elts[7],
             "Twosides"
              )
       
        # return the dictionary entry
        yield pddi
Ejemplo n.º 17
0
def OSCAR_Pickle_Generator():
    # open the OSCAR data file and parse it incrementally
    #
    # @returns: a PDDI drug model dictionary containing all of the data in a single
    #           OSCAR  PDDI.

    pddiDictL = []
    f = open(OSCAR_DATA, 'r')

    while 1:
        if not f:
            f.close()
            raise StopIteration

        l = f.readline()
        if l == "":
            f.close()
            break
        else:
            if l.find("Drug_1") != -1:  # skips header and stops at EOF
                l = f.readline()

        elts = l.strip("\n").split("$")
        pddi = getPDDIDict()
        (pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"],
         pddi["effectConcept"], pddi["severity"], pddi["evidence"],
         pddi["evidenceStatement"],
         pddi["source"]) = (elts[1], elts[3], elts[5], elts[7], elts[8],
                            elts[9], elts[10], elts[11], "OSCAR")

        print "object: %s: %s-- precipitant:%s : %s" % (
            pddi["object"], pddi["drug1"], pddi["precipitant"], pddi["drug2"])

        # return the dictionary entry
        pddiDictL.append(pddi)

    return pddiDictL
Ejemplo n.º 18
0
    print "OBSERVED DDIs query_string: %s" % query_string
    json_string = query(query_string, sparql_service)
    
    resultset=json.loads(json_string)

    #print resultset.values()
    print str(len(resultset["results"]["bindings"]))
    

    if len(resultset["results"]["bindings"]) == 0:
        print "INFO: No result!"
    else:
        #print json.dumps(resultset,indent=1)
        for i in range(0, len(resultset["results"]["bindings"])):
        #for i in range(10, 11):
             newPDDI = getPDDIDict()
             newPDDI["evidence"] = resultset["results"]["bindings"][i]["evidence"]["value"].encode("utf8")
             newPDDI["researchStatement"] = resultset["results"]["bindings"][i]["asrt"]["value"].encode("utf8")
             newPDDI["uri"] = resultset["results"]["bindings"][i]["s"]["value"].encode("utf8")

             obj =  resultset["results"]["bindings"][i]["object"]["value"].encode("utf8")
             newPDDI["object"] = obj.replace(u"http://dbmi-icode-01.dbmi.pitt.edu/dikb/resource/Drugs/",u"").upper().encode("utf8")

             precip = resultset["results"]["bindings"][i]["precip"]["value"].encode("utf8")
             newPDDI["precip"] = precip.replace(u"http://dbmi-icode-01.dbmi.pitt.edu/dikb/resource/Drugs/",u"").upper().encode("utf8")

             newPDDI["objectURI"] = resultset["results"]["bindings"][i]["objectURI"]["value"].encode("utf8")
             newPDDI["precipURI"] = resultset["results"]["bindings"][i]["precipURI"]["value"].encode("utf8")
             newPDDI["label"] = resultset["results"]["bindings"][i]["label"]["value"].encode("utf8")
             newPDDI["homepage"] = resultset["results"]["bindings"][i]["homepage"]["value"].encode("utf8")
             newPDDI["numericVal"] = resultset["results"]["bindings"][i]["numericVal"]["value"].encode("utf8")
                    skippedCnt += 1
                    continue

                # test for duplicate
                k1 = "%s-%s" % (drug1, drug2)
                k2 = "%s-%s" % (drug2, drug1)
                if keyDict.get(k1) != None or keyDict.get(k2) != None:
                    print "INFO: duplicate PDDI (%s) not adding to the list" % k1
                    dupCnt += 1
                    continue
                keyDict[k1] = None
                keyDict[k2] = None

                d1 = keggIdToDrugBankD.get(drug1).split("$")
                d2 = keggIdToDrugBankD.get(drug2).split("$")
                newPDDI = getPDDIDict()
                newPDDI["source"] = keggAPIURL
                newPDDI["uri"] = keggAPIURL + kd
                newPDDI["drug1"] = d1[0]
                newPDDI["object"] = d1[1]
                newPDDI["drug2"] = d2[0]
                newPDDI["precipitant"] = d2[1]
                newPDDI["source"] = "Kegg"

                if p_or_c == "P":
                    newPDDI["precaution"] = True
                else:
                    newPDDI["contraindication"] = True

                if pkMech == "unclassified":
                    newPDDI["ddiPkMechanism"] = pkMech