示例#1
0
def test_citekey_to_csl_item_pubmed_book():
    """
    Extracting CSL metadata from books in PubMed is not supported.
    Logic not implemented to parse XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=29227604&rettype=full
    """
    with pytest.raises(NotImplementedError):
        citekey_to_csl_item("pmid:29227604")
示例#2
0
def test_citekey_to_csl_item_pubmed_2():
    """
    Generated from XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=27094199&rettype=full
    """
    citekey = "pmid:27094199"
    csl_item = citekey_to_csl_item(citekey)
    print(csl_item)
    assert csl_item["id"] == "alaFV9OY"
    assert csl_item["type"] == "article-journal"
    assert csl_item["URL"] == "https://www.ncbi.nlm.nih.gov/pubmed/27094199"
    assert csl_item[
        "container-title"] == "Circulation. Cardiovascular genetics"
    assert csl_item["container-title-short"] == "Circ Cardiovasc Genet"
    assert csl_item["page"] == "179-84"
    assert (
        csl_item["title"] ==
        "Genetic Association-Guided Analysis of Gene Networks for the Study of Complex Traits."
    )
    assert csl_item["issued"]["date-parts"] == [[2016, 4]]
    authors = csl_item["author"]
    assert authors[0]["given"] == "Casey S"
    assert authors[0]["family"] == "Greene"
    assert csl_item["PMID"] == "27094199"
    assert csl_item["DOI"] == "10.1161/circgenetics.115.001181"
示例#3
0
def test_citekey_to_csl_item_clinical_trial():
    """
    Test clinicaltrials.gov citation support using CURIEs.
    https://github.com/manubot/manubot/issues/216
    """
    csl_item = citekey_to_csl_item("clinicaltrials:NCT04292899")
    assert csl_item["title"].startswith("A Phase 3 Randomized Study")
    assert csl_item["source"].startswith("clinicaltrials.gov")
    assert csl_item["URL"] == "https://clinicaltrials.gov/ct2/show/NCT04292899"
示例#4
0
def test_citekey_to_csl_item_pubmed_book(caplog):
    """
    Extracting CSL metadata from books in PubMed is not supported.
    Logic not implemented to parse XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=29227604&rettype=full
    """
    csl_item = citekey_to_csl_item("pmid:29227604", log_level="ERROR")
    assert csl_item is None
    assert "Unsupported PubMed record: no <Article> element" in caplog.text
示例#5
0
def test_citekey_to_csl_item_pubmed_with_numeric_month():
    """
    Generated from XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=29028984&rettype=full

    See https://github.com/manubot/manubot/issues/69
    """
    citekey = "pmid:29028984"
    csl_item = citekey_to_csl_item(citekey)
    print(csl_item)
    assert csl_item["issued"]["date-parts"] == [[2018, 3, 15]]
示例#6
0
def test_citekey_to_csl_item_pubmed_book(caplog):
    """
    Extracting CSL metadata from books in PubMed is not supported.
    Logic not implemented to parse XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=29227604&rettype=full
    """
    csl_item = citekey_to_csl_item("pmid:29227604", log_level="ERROR")
    assert csl_item is None
    assert (
        "Expected article to be an XML element with tag PubmedArticle, received tag 'PubmedBookArticle'"
        in caplog.text)
示例#7
0
def test_citekey_to_csl_item_doi_datacite():
    citekey = "doi:10.7287/peerj.preprints.3100v1"
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item["id"] == "11cb5HXoY"
    assert csl_item["URL"] == "https://doi.org/10.7287/peerj.preprints.3100v1"
    assert csl_item["DOI"] == "10.7287/peerj.preprints.3100v1"
    assert csl_item["type"] == "report"
    assert (csl_item["title"] ==
            "Sci-Hub provides access to nearly all scholarly literature")
    authors = csl_item["author"]
    assert authors[0]["family"] == "Himmelstein"
    assert authors[-1]["family"] == "Greene"
示例#8
0
def test_citekey_to_csl_item_doi_datacite():
    citekey = 'doi:10.7287/peerj.preprints.3100v1'
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item['id'] == '11cb5HXoY'
    assert csl_item['URL'] == 'https://doi.org/10.7287/peerj.preprints.3100v1'
    assert csl_item['DOI'] == '10.7287/peerj.preprints.3100v1'
    assert csl_item['type'] == 'report'
    assert csl_item[
        'title'] == 'Sci-Hub provides access to nearly all scholarly literature'
    authors = csl_item['author']
    assert authors[0]['family'] == 'Himmelstein'
    assert authors[-1]['family'] == 'Greene'
示例#9
0
def test_citekey_to_csl_item_arxiv():
    citekey = "arxiv:cond-mat/0703470v2"
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item["id"] == "ES92tcdg"
    assert csl_item["URL"] == "https://arxiv.org/abs/cond-mat/0703470v2"
    assert csl_item["number"] == "cond-mat/0703470v2"
    assert csl_item["version"] == "v2"
    assert csl_item["type"] == "report"
    assert csl_item["container-title"] == "arXiv"
    assert csl_item["title"] == "Portraits of Complex Networks"
    authors = csl_item["author"]
    assert authors[0]["literal"] == "J. P. Bagrow"
    assert csl_item["DOI"] == "10.1209/0295-5075/81/68004"
示例#10
0
def test_citekey_to_csl_item_arxiv():
    citekey = 'arxiv:cond-mat/0703470v2'
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item['id'] == 'ES92tcdg'
    assert csl_item['URL'] == 'https://arxiv.org/abs/cond-mat/0703470v2'
    assert csl_item['number'] == 'cond-mat/0703470v2'
    assert csl_item['version'] == '2'
    assert csl_item['type'] == 'report'
    assert csl_item['container-title'] == 'arXiv'
    assert csl_item['title'] == 'Portraits of Complex Networks'
    authors = csl_item['author']
    assert authors[0]['literal'] == 'J. P. Bagrow'
    assert csl_item['DOI'] == '10.1209/0295-5075/81/68004'
示例#11
0
def test_citekey_to_csl_item_pmc():
    """
    https://api.ncbi.nlm.nih.gov/lit/ctxp/v1/pmc/?format=csl&id=3041534
    """
    citekey = f'pmcid:PMC3041534'
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item['id'] == 'RoOhUFKU'
    assert csl_item[
        'URL'] == 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3041534/'
    assert csl_item['container-title-short'] == 'Summit Transl Bioinform'
    assert csl_item[
        'title'] == 'Secondary Use of EHR: Data Quality Issues and Informatics Opportunities'
    authors = csl_item['author']
    assert authors[0]['family'] == 'Botsis'
    assert csl_item['PMID'] == '21347133'
    assert csl_item['PMCID'] == 'PMC3041534'
    assert 'generated by Manubot' in csl_item['note']
    assert 'standard_id: pmcid:PMC3041534' in csl_item['note']
示例#12
0
def getPaperTitleFromIssue(issue):
    """ gets the papers title using manubot; if manubot can't get title, extract from issue title """
    try:
        # Try using manubot
        citekey = getCitationFromIssue(issue)
        csl_item = cite.citekey_to_csl_item(citekey)
        title = csl_item["title"]
        return title
    except:
        # On error, try getting from issue title
        try:
            title = issue["title"].split(":")[1]
            return title
        except:
            print(
                "the paper title could not be automatically extracted from the following issue: \n",
                issue["title"])
            return "unknown"
示例#13
0
def test_citekey_to_csl_item_pmc():
    """
    https://api.ncbi.nlm.nih.gov/lit/ctxp/v1/pmc/?format=csl&id=3041534
    """
    citekey = f"pmcid:PMC3041534"
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item["id"] == "RoOhUFKU"
    assert csl_item["URL"] == "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3041534/"
    assert csl_item["container-title-short"] == "Summit Transl Bioinform"
    assert (
        csl_item["title"]
        == "Secondary Use of EHR: Data Quality Issues and Informatics Opportunities"
    )
    authors = csl_item["author"]
    assert authors[0]["family"] == "Botsis"
    assert csl_item["PMID"] == "21347133"
    assert csl_item["PMCID"] == "PMC3041534"
    assert "generated by Manubot" in csl_item["note"]
    assert "standard_id: pmcid:PMC3041534" in csl_item["note"]
示例#14
0
def test_citekey_to_csl_item_pubmed_1():
    """
    Generated from XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=21347133&rettype=full
    """
    citekey = 'pmid:21347133'
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item['id'] == 'y9ONtSZ9'
    assert csl_item['type'] == 'article-journal'
    assert csl_item['URL'] == 'https://www.ncbi.nlm.nih.gov/pubmed/21347133'
    assert csl_item[
        'container-title'] == 'Summit on translational bioinformatics'
    assert csl_item[
        'title'] == 'Secondary Use of EHR: Data Quality Issues and Informatics Opportunities.'
    assert csl_item['issued']['date-parts'] == [[2010, 3, 1]]
    authors = csl_item['author']
    assert authors[0]['given'] == 'Taxiarchis'
    assert authors[0]['family'] == 'Botsis'
    assert csl_item['PMID'] == '21347133'
    assert csl_item['PMCID'] == 'PMC3041534'
示例#15
0
def test_citekey_to_csl_item_pubmed_1():
    """
    Generated from XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=21347133&rettype=full
    """
    citekey = "pmid:21347133"
    csl_item = citekey_to_csl_item(citekey)
    assert csl_item["id"] == "y9ONtSZ9"
    assert csl_item["type"] == "article-journal"
    assert csl_item["URL"] == "https://www.ncbi.nlm.nih.gov/pubmed/21347133"
    assert csl_item["container-title"] == "Summit on translational bioinformatics"
    assert (
        csl_item["title"]
        == "Secondary Use of EHR: Data Quality Issues and Informatics Opportunities."
    )
    assert csl_item["issued"]["date-parts"] == [[2010, 3, 1]]
    authors = csl_item["author"]
    assert authors[0]["given"] == "Taxiarchis"
    assert authors[0]["family"] == "Botsis"
    assert csl_item["PMID"] == "21347133"
    assert csl_item["PMCID"] == "PMC3041534"
示例#16
0
def test_citekey_to_csl_item_pubmed_2():
    """
    Generated from XML returned by
    https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=27094199&rettype=full
    """
    citekey = 'pmid:27094199'
    csl_item = citekey_to_csl_item(citekey)
    print(csl_item)
    assert csl_item['id'] == 'alaFV9OY'
    assert csl_item['type'] == 'article-journal'
    assert csl_item['URL'] == 'https://www.ncbi.nlm.nih.gov/pubmed/27094199'
    assert csl_item[
        'container-title'] == 'Circulation. Cardiovascular genetics'
    assert csl_item['container-title-short'] == 'Circ Cardiovasc Genet'
    assert csl_item['page'] == '179-84'
    assert csl_item[
        'title'] == 'Genetic Association-Guided Analysis of Gene Networks for the Study of Complex Traits.'
    assert csl_item['issued']['date-parts'] == [[2016, 4]]
    authors = csl_item['author']
    assert authors[0]['given'] == 'Casey S'
    assert authors[0]['family'] == 'Greene'
    assert csl_item['PMID'] == '27094199'
    assert csl_item['DOI'] == '10.1161/circgenetics.115.001181'
示例#17
0
def test_citekey_to_csl_item_isbn():
    csl_item = citekey_to_csl_item("isbn:9780387950693")
    assert csl_item["type"] == "book"
    assert csl_item["title"] == "Complex analysis"
示例#18
0
def test_citekey_to_csl_item_isbn():
    csl_item = citekey_to_csl_item('isbn:9780387950693')
    assert csl_item['type'] == 'book'
    assert csl_item['title'] == 'Complex analysis'