Ejemplo n.º 1
0
def insert_abstract(nex_session, pmid, reference_id, record, source_id, journal_abbrev, journal_title, issn_print):

    text = record.get('AB', '')

    if text == '':
        return
    
    x = Referencedocument(document_type = 'Abstract',
                          source_id = source_id,
                          reference_id = reference_id,
                          text = text,
                          html = link_gene_names(text, {}, nex_session),
                          created_by = CREATED_BY)
    nex_session.add(x)
    
    entries = create_bibentry(pmid, record, journal_abbrev, journal_title, issn_print)
    y = Referencedocument(document_type = 'Medline',
                          source_id = source_id,
                          reference_id = reference_id,
                          text = '\n'.join([key + ' - ' + str(value) for key, value in entries if value is not None]),
                          html = '\n'.join([key + ' - ' + str(value) for key, value in entries if value is not None]),
                          created_by = CREATED_BY)
    nex_session.add(y)
    nex_session.flush()
    nex_session.refresh(x)
Ejemplo n.º 2
0
def update_abstract(nex_session, fw, pmid, reference_id, abstract, abstract_db,
                    source_id, update_log, updated_pmids):

    if abstract is None or abstract == "" or len(abstract) < 10:
        return
    if abstract == abstract_db:
        return

    update_log['abstract'] = update_log['abstract'] + 1

    if pmid not in updated_pmids:
        updated_pmids.append(pmid)

    if abstract_db is None:
        x = Referencedocument(document_type='Abstract',
                              source_id=source_id,
                              reference_id=reference_id,
                              text=abstract,
                              html=link_gene_names(abstract, {}, nex_session),
                              created_by=CREATED_BY)
        nex_session.add(x)
        nex_session.commit()
        fw.write("PMID:" + str(pmid) +
                 ": new abstract added.\nNew abstract: " + abstract + "\n")
    else:
        nex_session.query(Referencedocument).filter_by(
            reference_id=reference_id).update({
                'text':
                abstract,
                'html':
                link_gene_names(abstract, {}, nex_session)
            })
        nex_session.commit()
        fw.write("PMID=" + str(pmid) +
                 ": the abstract is updated.\nNew abstract: " + abstract +
                 "\nOld abstract: " + abstract_db + "\n\n")
def update_abstract(nex_session, fw, pmid, reference_id, abstract,
                    abstract_db):

    if abstract is None or abstract == "" or len(abstract) < 10:
        return
    if abstract == abstract_db or abstract_db is None:
        return

    nex_session.query(Referencedocument).filter_by(
        reference_id=reference_id).update({
            'text':
            abstract,
            'html':
            link_gene_names(abstract, {}, nex_session)
        })
    nex_session.commit()