Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support autoretrieval of formatted reference from PMID. #46

Open
kcs3 opened this issue Nov 4, 2019 · 1 comment
Open

Support autoretrieval of formatted reference from PMID. #46

kcs3 opened this issue Nov 4, 2019 · 1 comment
Assignees

Comments

@kcs3
Copy link
Collaborator

kcs3 commented Nov 4, 2019

A comment initially entered into the Dashboard Github was "Support autoretrieval of formatted reference from PMID." It was issue CBIIT/nci-ctd2-dashboard#415.

There is an API to retrieve a formatted journal reference from PubMed given the PubMed ID. This is a request to implement this feature in the submission builder.

The formatted journal reference only appears in the Description text field of the publication_reference column. So we will need to design how this is going to be implemented.

@vdancik
Copy link

vdancik commented Nov 5, 2019

Python script to format reference display text:

import sys
from urllib.request import urlopen


def main():
    if len(sys.argv) < 2:
        print('ERROR: PMID not specified', file=sys.stderr)
        sys.exit(2)
    nAuthors = 0
    pmid = sys.argv[1]
    print('pmid = '+pmid)
    url = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=text&rettype=medline&id='+pmid
    print('url = '+url+'\n')
    response = urlopen(url)
    for input in response:

        line = input.decode('utf-8')
        print(line.strip('\n'))
        if line.startswith('    '):
            #print('last prefix = "'+lastPrefix+'"')
            if lastPrefix == 'TI  ':
                title = title + ' ' + line.strip()
            if lastPrefix == 'SO  ':
                reference = reference + ' ' + line.strip()
        lastPrefix = line[0:4]
        if line.startswith('TI  - '):
            #print('TITLE = '+line)
            title = line[6:].strip()
        if line.startswith('SO  - '):
            #print('REF = '+line)
            reference = line[6:].strip()
        if line.startswith('AU  - '):
            #print('AUTHOR = '+line)
            nAuthors = nAuthors + 1
            if nAuthors == 1:
                firstAuthor = line[6:].strip()
            if nAuthors == 2:
                secondAuthor = line[6:].strip()

    author = firstAuthor
    if nAuthors > 2:
        author = author + ' et al.'
    if nAuthors == 2:
        author = author + ' and ' + secondAuthor
    print('\nAUTHOR = '+author)
    print('TITLE = '+title)
    print('REF = '+reference)
    print(author+': '+title+' '+reference)

if __name__ == '__main__':
    main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants