示例#1
0
def get_journal_id(record, created_by):
    journal_abbr = record.get('TA', '')
    journal_full_name = record.get('JT', '')

    # 1469-221X (Print) 1469-221X (Linking)
    # 1573-6881 (Electronic) 0145-479X (Linking)
    issn_list = record.get('IS', '').split(') ')
    issn_print = ''
    issn_electronic = ''
    for issn in issn_list:
        if "Print" in issn or "Linking" in issn:
            issn_print = issn.split(' ')[0]
        if "Electronic" in issn:
            issn_electronic = issn.split(' ')[0]
    if issn_print:
        journals = DBSession.query(Journal).filter_by(
            issn_print=issn_print).all()
        if len(journals) > 0:
            return journals[0].journal_id, journals[
                0].med_abbr, journal_full_name, issn_print

    if journal_abbr == '':
        return None, '', '', ''

    if journal_abbr:
        journals = DBSession.query(Journal).filter_by(
            med_abbr=journal_abbr).all()
        if len(journals) > 0:
            return journals[0].journal_id, journals[
                0].med_abbr, journal_full_name, issn_print

    source_id = 824  # 'PubMed'
    shortened_full_name = (
        journal_full_name[:197] +
        '...') if len(journal_full_name) > 200 else journal_full_name
    format_name = journal_full_name.replace(' ', '_') + journal_abbr.replace(
        ' ', '_')

    j = Journal(issn_print=issn_print,
                issn_electronic=issn_electronic,
                display_name=shortened_full_name,
                format_name=(format_name[:97] +
                             '...') if len(format_name) > 100 else format_name,
                title=shortened_full_name,
                med_abbr=journal_abbr,
                source_id=source_id,
                obj_url='/journal/' + format_name,
                created_by=created_by)
    DBSession.add(j)
    DBSession.flush()
    DBSession.refresh(j)

    return j.journal_id, j.med_abbr, journal_full_name, issn_print
示例#2
0
def get_journal_id(nex_session, record, source_id=None):

    journal_abbr = record.get('TA', '')
    journal_full_name = record.get('JT', '')

    # 1469-221X (Print) 1469-221X (Linking)
    # 1573-6881 (Electronic) 0145-479X (Linking)
    issn_list = record.get('IS', '').split(') ')
    issn_print = ''                                                                 
    issn_electronic = ''
    for issn in issn_list:
        if "Print" in issn or "Linking" in issn:
            issn_print = issn.split(' ')[0]
        if "Electronic" in issn:
            issn_electronic = issn.split(' ')[0]
    if issn_print:
        journals = nex_session.query(Journal).filter_by(issn_print=issn_print).all()
        if len(journals) > 0:
            return journals[0].journal_id, journals[0].med_abbr, journal_full_name, issn_print
    if journal_abbr:
        journals = nex_session.query(Journal).filter_by(med_abbr=journal_abbr).all()
        if len(journals) > 0:
            return journals[0].journal_id, journals[0].med_abbr, journal_full_name, issn_print

    if source_id is None:
        source_id = get_source_id(nex_session, 'PubMed')

    format_name = journal_full_name.replace(' ', '_') + journal_abbr.replace(' ', '_')
    j = Journal(issn_print = issn_print,
                issn_electronic = issn_electronic,
                display_name = journal_full_name,
                format_name = format_name,
                title = journal_full_name,
                med_abbr = journal,
                source_id = source_id,
                obj_url = '/journal/'+format_name,
                created_by = CREATED_BY)
    nex_session.add(j)
    nex_session.flush()
    nex_session.refresh(x)
    return j.journal_id, j.med_abbr, journal_full_name, issn_print
示例#3
0
def get_journal_id(record, created_by):
    journal_abbr = record.get('journal_abbrev', '')
    journal_full_name = record.get('journal_title', '')
    issn_print = record.get('issn_print')
    issn_electronic = record.get('issn_electronic')

    if issn_print:
        journals = DBSession.query(Journal).filter_by(
            issn_print=issn_print).all()
        if len(journals) > 0:
            return journals[0].journal_id, journals[
                0].med_abbr, journal_full_name, issn_print
    if journal_abbr:
        journals = DBSession.query(Journal).filter_by(
            med_abbr=journal_abbr).all()
        if len(journals) > 0:
            return journals[0].journal_id, journals[
                0].med_abbr, journal_full_name, issn_print

    source_id = 824  # 'PubMed'

    # format_name = journal_full_name.replace(' ', '_') + journal_abbr.replace(' ', '_')
    journal_full_name = journal_full_name.split(" : ")[0]
    format_name = journal_full_name.replace(' ', '_')

    j = Journal(issn_print=issn_print,
                issn_electronic=issn_electronic,
                display_name=journal_full_name,
                format_name=format_name,
                title=journal_full_name,
                med_abbr=journal_abbr,
                source_id=source_id,
                obj_url='/journal/' + format_name,
                created_by=created_by)
    DBSession.add(j)
    DBSession.flush()
    DBSession.refresh(j)

    return j.journal_id, j.med_abbr, journal_full_name, issn_print
示例#4
0

def get_words(x):
    return ' '.join(sample(['Hello', 'World', 'Great', 'Neo4j', 'Project', '.']*5, x))


def get_date():
    return date(1990+randint(1, 20), randint(1, 12), randint(1, 28))


print('Creating sample data...')

for article_index in range(randint(8, 12)):
    pmid = get_pmid()
    print(f'Create relationship with article {article_index+1}:{pmid}...')
    journal = Journal(issn=get_words(3)).merge()
    article = Paper(
        pmid=pmid,
        # Some data may be missing
        doi=get_pmid() if random() > 0.8 else '',
        title=get_words(randint(5, 8)),
        date=get_date(),
        date_type="emmm"
    ).merge()
    article.publish_on.connect(journal)

    for refer_index in range(randint(10, 20)):
        reference = Paper(pmid=get_pmid(), date=get_date(), date_type="emmm").merge()
        reference.cited_by.connect(article)
    for refer_index in range(randint(10, 20)):
        reference = Paper(pmid=get_pmid(), date=get_date(), date_type="emmm").merge()