Beispiel #1
0
def discard_ref(pmid):

    try:       
        RefTemp.delete(pmid)
        RefBad.insert(pmid, current_user.name.upper())
        db.session.commit()
    except:
        db.session.rollback()
        return "An error occurred when deleting the reference for pmid=" + pmid + " from the database."
    return "Reference for pmid=" + pmid + " has been removed from the database!"
Beispiel #2
0
    def insert_and_associate(self):

        ref_no = Reference.insert(self.pmid, self.user)
        RefTemp.delete(self.pmid)

        lg_feat_hash = {}
        message = ''
        topic_added = {}
        task_added = {}

        if len(self.tasks) == 0:
            return None

        for task_entry in self.tasks:

            task = task_entry[0]
            genes = task_entry[1]
            comment = task_entry[2]

            if len(genes) > 0:

                feat_no_list = []

                topic = ''
                if 'Add to' in task:
                    topic = 'Additional Literature'
                elif 'Review' in task:
                    topic = task
                else:
                    topic = 'Primary Literature'

                if 'Review' in task or 'Add to' in task:
                    task = 'Gene Link'

                message += "Curation_task = '" + task
                message += "', literature_topic = '" + topic + "'"
                message += ", gene = "

                for name in genes:
                    feat_no = self.feature_no_for_name[name]
                    feat_no_list.append(feat_no)
                    ## insert into ref_curation
                    if not task_added.has_key((feat_no, task)):
                        RefCuration.insert(ref_no, task, self.user, feat_no,
                                           comment)
                        task_added[(feat_no, task)] = 1
                    message += name + '|'

                if comment:
                    message += ", comment = '" + comment + "'"

                message += "<br>"

                ## insert into lit_guide + litguide_feat

                if topic_added.has_key(topic):
                    litguide_no = topic_added[topic]
                else:
                    litguide_no = LitGuide.insert(ref_no, topic, self.user)
                    topic_added[topic] = litguide_no

                for feat_no in feat_no_list:
                    key = (feat_no, litguide_no)
                    if lg_feat_hash.has_key(key):
                        continue
                    lg_feat_hash[key] = 1
                    LitGuideFeat.insert(feat_no, litguide_no)

            else:  ## no gene name provided

                ## if no gene name provided and "Add to database" was checked,
                ## no need to add any association
                if 'Add' in task:
                    continue

                ## if it is a review, no need to add to ref_curation
                if 'Review' in task:
                    ## topic = task = 'Reviews'
                    LitGuide.insert(ref_no, task, self.user)
                    message += "Literature_topic = '" + task + "'<br>"
                    continue

                if not task_added.has_key((0, task)):
                    RefCuration.insert(ref_no, task, self.user, None, comment)
                    task_added[(0, task)] = 1

                    message += "Curation_task = '" + task + "'"

                ## insert into lit_guide
                if 'HTP' in task or 'Review' in task:

                    topic = ''
                    if 'HTP' in task:
                        topic = 'Omics'
                    else:
                        # 'Review' in task:
                        topic = task

                    if topic_added.has_key(topic):
                        if comment:
                            message += ", comment = '" + comment + "'"
                        message += "<br>"
                        continue
                    else:
                        lit_guide_no = LitGuide.insert(ref_no, topic,
                                                       self.user)
                        topic_added[topic] = lit_guide_no
                        message += ", literature_topic = '" + topic

                if comment:
                    message += ", comment = '" + comment + "'"

                message += "<br>"

            db.session.commit()

        return message
Beispiel #3
0
    def insert_and_associate(self):
    
        ref_no = Reference.insert(self.pmid, self.user)
        RefTemp.delete(self.pmid)
        
        lg_feat_hash = {}
        message = ''
        topic_added = {}
        task_added = {}

        if len(self.tasks) == 0:
            return None

        for task_entry in self.tasks:
        
            task = task_entry[0]    
            genes = task_entry[1]
            comment = task_entry[2]
            
            if len(genes) > 0:

                feat_no_list = []
            
                topic = ''
                if 'Add to' in task:
                    topic = 'Additional Literature'
                elif 'Review' in task:
                    topic = task
                else:
                    topic = 'Primary Literature'
            
                if 'Review' in task or 'Add to' in task:
                    task = 'Gene Link'

                message += "Curation_task = '" + task
                message += "', literature_topic = '" + topic + "'"
                message += ", gene = "
                 
                for name in genes:
                    feat_no = self.feature_no_for_name[name]
                    feat_no_list.append(feat_no)
                    ## insert into ref_curation
                    if not task_added.has_key((feat_no, task)):
                        RefCuration.insert(ref_no, task, self.user, feat_no, comment)            
                        task_added[(feat_no, task)] = 1
                    message += name + '|'

                if comment:
                    message += ", comment = '" + comment + "'"
                    
                message += "<br>"
            
                ## insert into lit_guide + litguide_feat
            
                if topic_added.has_key(topic):
                    litguide_no = topic_added[topic]
                else:
                    litguide_no = LitGuide.insert(ref_no, topic, self.user)
                    topic_added[topic] = litguide_no
            
                for feat_no in feat_no_list:
                    key = (feat_no, litguide_no)
                    if lg_feat_hash.has_key(key):
                        continue
                    lg_feat_hash[key] = 1
                    LitGuideFeat.insert(feat_no, litguide_no)
                    
            else:   ## no gene name provided

                ## if no gene name provided and "Add to database" was checked,
                ## no need to add any association
                if 'Add' in task:
                    continue

                ## if it is a review, no need to add to ref_curation
                if 'Review' in task:
                    ## topic = task = 'Reviews'
                    LitGuide.insert(ref_no, task, self.user)
                    message += "Literature_topic = '" + task + "'<br>"
                    continue

                if not task_added.has_key((0, task)):
                    RefCuration.insert(ref_no, task, self.user, None, comment)
                    task_added[(0, task)] = 1
                
                    message += "Curation_task = '" + task + "'"
            
                ## insert into lit_guide 
                if 'HTP' in task or 'Review' in task:

                    topic = ''
                    if 'HTP' in task:
                        topic = 'Omics'
                    else:
                        # 'Review' in task:
                        topic = task
                    
                    if topic_added.has_key(topic):
                        if comment:
                            message += ", comment = '" + comment + "'"
                        message += "<br>"
                        continue
                    else:    
                        lit_guide_no = LitGuide.insert(ref_no, topic, self.user)
                        topic_added[topic] = lit_guide_no 
                        message += ", literature_topic = '" + topic

                if comment:
                    message += ", comment = '" + comment + "'"
                    
                message += "<br>"
                
            db.session.commit()

        return message