Пример #1
0
 def initNew(self, connection, listname='', xreflsid='', obkeywords=''):
     """ method to initialise a new labResourceList Module object """
     self.databaseFields = \
         { 'listname' : listname, 'obid' : getNewObid(connection) , 'xreflsid' : xreflsid , \
         'obkeywords' : obkeywords
           }
     self.obState.update({'DB_PENDING': 1, 'ERROR': 0})
Пример #2
0
    def initNew(self, connection):

        self.databaseFields = {
            'obid': getNewObid(connection),
            'xreflsid': None,
            'oblist': None,
            'ob': None
        }
        self.obState.update({'NEW': 1, 'DB_PENDING': 1})
Пример #3
0
    def addTerm(self,
                connection,
                termname,
                checkexisting=True,
                termdescription=None,
                unitname=None,
                termcode=None):
        """ this method can be used to add a term to an ontology. The method will
        check that the term does not already exist, and will only add it if it does
        not exist, if the checkexisting parameter is True (set False if importing and
        sure there is no existing data, as this will speed up the transaction)
        """
        termDict = {
            'ontologyob': self.databaseFields['obid'],
            'xreflsid': "%s.%s" % (self.databaseFields['xreflsid'], termname),
            'termname': termname,
            'termdescription': termdescription,
            'unitname': unitname,
            'termcode': termcode
        }

        insertCursor = connection.cursor()
        if checkexisting:
            # if required check if this term is already in the db - if it is do not duplicate
            sql = """
            select obid from ontologytermfact where
            ontologyob = %(ontologyob)s and
            termname  = %(termname)s """
            ontologymodulelogger.info("checking for term using %s" %
                                      (sql % termDict))
            insertCursor.execute(sql, termDict)
            row = insertCursor.fetchone()
            ontologymodulelogger.info("rowcount = %s" % insertCursor.rowcount)
            if insertCursor.rowcount > 0:
                insertCursor.close()
                return (row[0], False)

        # do the insert
        termDict.update({'obid': getNewObid(connection)})
        sql = """
        insert into ontologytermfact(obid,ontologyob,xreflsid,termname,termdescription,
        unitname,termcode)
        values(%(obid)s,%(ontologyob)s,%(xreflsid)s,%(termname)s,
        %(termdescription)s,%(unitname)s,%(termcode)s)
        """
        ontologymodulelogger.info("executing %s" % (sql % termDict))
        insertCursor.execute(sql, termDict)
        connection.commit()
        insertCursor.close()
        self.obState.update({
            'NEW': 0,
            'DB_PENDING': 0,
            'ERROR': 0,
            'MESSAGE': "database insert OK"
        })
        return (termDict['obid'], True)
Пример #4
0
 def initNew(self, connection):
     """ method to initialise a new biosample object """
     self.databaseFields = {
         'obid': getNewObid(connection),
         'xreflsid': None,
         'listname': None,
         'maxmembership': None,
         'listcomment': None
     }
     self.obState.update({'DB_PENDING': 1})
Пример #5
0
 def initNew(self,connection):
     self.obState.update({'NEW' : 1, 'DB_PENDING' : 1})        
     self.databaseFields = {
         'obid' : getNewObid(connection) ,
         'xreflsid' : None,
         'libaryname' : None,
         'librarytype' : None,
         'librarydate' : None,
         'librarydescription' : None,
         'librarystorage' : None}
Пример #6
0
    def initNew(self, connection):
        self.obState.update({'NEW': 1, 'DB_PENDING': 1})

        self.databaseFields = {
            'obid': getNewObid(connection),
            'ontologyname': None,
            'ontologydescription': None,
            'xreflsid': None,
            'ontologycomment': None
        }
Пример #7
0
    def initNew(self, connection):
        self.obState.update({'NEW': 1, 'DB_PENDING': 1})

        self.databaseFields = {
            'obid': getNewObid(connection),
            'createdby': None,
            'uritype': None,  # not currently initialised
            'uristring': None,
            'xreflsid': None,
            'visibility': None,
            'uricomment': None
        }
Пример #8
0
 def initNew(self, connection):
     """ method to initialise a new functional assay fact object """
     self.databaseFields = \
         {
             'obid' : getNewObid(connection) ,
             'assayName' : None,
             'xreflsid' : None ,
             'labresourceob' : None,
             'assaytype'  : None,
             'assaydescription' : None
         }
     self.obState.update({'DB_PENDING': 1})
Пример #9
0
 def initNew(self, connection):
     """ method to initialise a new biosubject object """
     self.databaseFields = {
         'obid': getNewObid(connection),
         'subjectname': None,
         'xreflsid': None,
         'strain': None,
         'subjectdescription': None,
         'subjectspeciesname': None,
         'dob': None,
         'sex': None
     }
     self.obState.update({'DB_PENDING': 1})
Пример #10
0
    def initNew(self,connection):      
        self.obState.update({'NEW' : 1, 'DB_PENDING' : 1})

        self.databaseFields = {
            'biosequenceob' : None,
            'obid' : getNewObid(connection) ,
            'featuretype' : None,   
            'featurestart' : None,  
            'featurestop' : None  , 
            'featurestrand' : None ,
            'featurecomment' : None,
            'featureaccession' : None
        }         
Пример #11
0
    def initNew(self, connection):

        self.databaseFields = {
            'obid': getNewObid(connection),
            'xreflsid': None,
            'createdby': None,
            'obkeywords': None,
            'subjectob': None,
            'objectob': None,
            'predicate': None,
            'predicatecomment': None
        }
        self.obState.update({'NEW': 1, 'DB_PENDING': 1})
Пример #12
0
    def initNew(self, connection):
        self.obState.update({'NEW': 1, 'DB_PENDING': 1})

        self.databaseFields = {
            'obid': getNewObid(connection),
            'createdby': None,
            'commenttype': None,
            'commentstring': None,
            'xreflsid': None,
            'visibility': None,
            'commentedob': None,
            'voptypeid': None
        }
Пример #13
0
 def initNew(self, connection):
     """ method to initialise a new geneticTestFact object """
     self.databaseFields = \
         {
             'obid' : getNewObid(connection) ,
             'accession' : None,
             'xreflsid' : None ,
             'labresourceob' : None,
             'testtype'  : None,
             'locusname' : None,
             'testdescription' : None,
             'variation' : None
         }
     self.obState.update({'DB_PENDING': 1})
Пример #14
0
 def initNew(self, connection):
     """ method to initialise a new biosubject object """
     self.databaseFields = {
         'obid': getNewObid(connection),
         'loginname': None,
         'fullname': None,
         'emailaddress': None,
         'mobile': None,
         'phone': None,
         'title': None,
         'staffcomment': None,
         'xreflsid': None
     }
     self.obState.update({'DB_PENDING': 1})
Пример #15
0
 def initNew(self, connection):
     """ method to initialise a new biosample object """
     self.databaseFields = {
         'obid': getNewObid(connection),
         'batchname': None,
         'xreflsid': None,
         'batchtype': None,
         'batchname': None,
         'membershipcount': 0,
         'batchdescription': None,
         'batchkeywords': None,
         'batchstatus': None
     }
     self.obState.update({'DB_PENDING': 1})
Пример #16
0
    def initNew(self,connection):      
        self.obState.update({'NEW' : 1, 'DB_PENDING' : 1})

        self.databaseFields = {
            'obid' : getNewObid(connection) ,
            'sequencename' : None,
            'sequencedescription' : None,
            'xreflsid' : None,
            'sequencetype' : None,
            'seqstring' : None,
            'seqlength' : None,
            'sequenceurl' : None,
            'seqcomment' : None,
            'fnindex_accession' : None,
            'fnindex_id' : None
        }         
Пример #17
0
 def initNew(self,
             connection,
             resourcetype,
             xreflsid='',
             obkeywords='',
             resourcedescription=''):
     """ method to initialise a new labResourceModule object """
     self.databaseFields = \
         {
             'obid' : getNewObid(connection) ,
             'xreflsid' : xreflsid ,
             'obkeywords' : obkeywords ,
             'resourcetype' : resourcetype ,
             'resourcename' : xreflsid ,
             'resourcedescription' : resourcedescription ,
             'resourcesequence' : None
           }
     self.obState.update({'DB_PENDING': 1})
Пример #18
0
    def initNew(self, connection):

        self.databaseFields = {
            'obid': getNewObid(connection),
            'xreflsid': None,
            'createdby': None,
            'obkeywords': None,
            'listob': None,
            'experimenttitle': None,
            'experimentseriestype': None,
            'experimentplatforms': None,
            'experimentsummary': None,
            'experimentdesign': None,
            #'r_targetfile' : None,
            #'r_misc' : None,
            'contributors': None
        }
        self.obState.update({'NEW': 1, 'DB_PENDING': 1})
Пример #19
0
 def initNew(self, connection):
     """ method to initialise a new biosample object """
     self.databaseFields = {
         'obid': getNewObid(connection),
         'samplename': None,
         'xreflsid': None,
         'sampletype': None,
         'sampledate': None,
         'sampletissue': None,
         'sampledescription': None,
         'samplestorage': None,
         'samplecount': None,
         'sampleweight': None,
         'sampleweightunit': None,
         'samplevolume': None,
         'samplevolumeunit': None,
         'sampledrymatterequiv': None,
         'sampledmeunit': None
     }
     self.obState.update({'DB_PENDING': 1})
Пример #20
0
    def initNew(self, connection):

        self.databaseFields = {
            'obid': getNewObid(connection),
            'xreflsid': None,
            'listname': None,
            'listtype': None,
            'listdefinition': None,
            'bookmark': None,
            'maxmembership': 1000000,
            'currentmembership': 0,
            'listcomment': None,
            'createdby': None,
            'obkeywords': None,
            'displayurl': 'ob.gif',
            'listitems':
            [],  # this is subject to chunk processing and will contain "pages" of items
            'alllistitems': []  # this will contain all list items
        }
        self.chunkSize = 1000
        self.obState.update({'NEW': 1})
Пример #21
0
    def addFeature(self,connection,featureDict, featureAttributes = None, checkExisting = False):
        featureDict.update ({
            'biosequenceob' : self.databaseFields['obid'],
            'xreflsid' : "%s.feature.%s"%(self.databaseFields['xreflsid'],featureDict['featuretype']),
            'featurestrand' : eval({True : 'featureDict["featurestrand"]', False : "None"}[featureDict.has_key("featurestrand")]),
            'featurestart' : eval({True : 'featureDict["featurestart"]', False : "None"}[featureDict.has_key("featurestart")]),            
            'featurestop' : eval({True : 'featureDict["featurestop"]', False : "None"}[featureDict.has_key("featurestop")]),
            'featurecomment' : eval({True : 'featureDict["featurecomment"]', False : "None"}[featureDict.has_key("featurecomment")]),
            'featureaccession' : eval({True : 'featureDict["featureaccession"]', False : "None"}[featureDict.has_key("featureaccession")]),
            'featurelength' : eval({True : 'featureDict["featurelength"]', False : "None"}[featureDict.has_key("featurelength")]),
            'evidence' : eval({True : 'featureDict["evidence"]', False : "None"}[featureDict.has_key("evidence")])              
            })

        insertCursor = connection.cursor()
        
        # first check if this feature is already in the db - if it is do not duplicate
        featureExists = False
        if checkExisting:
            sql = """
            select obid from biosequencefeaturefact where
            biosequenceob = %(biosequenceob)s and
            featuretype = %(featuretype)s """
            if featureDict['featurestart'] != None:
                sql += " and featurestart = %(featurestart)s "
            if featureDict['featurestop'] != None:
                sql += " and featurestop = %(featurestop)s "
            if featureDict['featurestrand'] != None:
                sql += " and featurestrand = %(featurestrand)s "
            if featureDict['featurelength'] != None:
                sql += " and featurelength = %(featurelength)s "            
            sequencemodulelogger.info("checking for feature using %s"%(sql%featureDict))
            insertCursor.execute(sql,featureDict)
            insertCursor.fetchone()
            sequencemodulelogger.info("rowcount = %s"%insertCursor.rowcount)

            if insertCursor.rowcount != 0:
                featureExists = True
                
            
        if not featureExists:
            featureDict.update ({
                'obid' : getNewObid(connection)
            })
            
            sql = """
            insert into bioSequenceFeatureFact(obid,biosequenceob,xreflsid,featuretype,featurestrand,featurestart,featurestop,featurecomment,
            evidence,featurelength)
            values(%(obid)s,%(biosequenceob)s,%(xreflsid)s,%(featuretype)s,%(featurestrand)s,%(featurestart)s,%(featurestop)s,%(featurecomment)s,
            %(evidence)s,%(featurelength)s)
            """
            sequencemodulelogger.info("executing %s"%(sql%featureDict))
            insertCursor.execute(sql,featureDict)
            connection.commit()


            # if necessary add feature attributes
            if featureAttributes != None:
                if len(featureAttributes) > 0:
                    for attribute in featureAttributes:
                        sql = """
                        insert into biosequencefeatureattributefact( biosequencefeaturefact , factnamespace , attributename , attributevalue)
                        values(%(biosequencefeaturefact)s , %(factnamespace)s , %(attributename)s , %(attributevalue)s)
                        """

                        insertCursor.execute(sql,{
                            'biosequencefeaturefact' : featureDict.obid,
                            'factnamespace' : attribute[0],
                            'attributename' : attribute[1],
                            'attributevalue' : attribute[2] })
                    connection.commit()
                            
            insertCursor.close()
            self.obState.update({'NEW' : 0 , 'DB_PENDING' : 0, 'ERROR' : 0, 'MESSAGE' : "database insert OK"})

            
        else:
            insertCursor.close()