-
Notifications
You must be signed in to change notification settings - Fork 0
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
Ncbi tests #86
Merged
Merged
Ncbi tests #86
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e2f9e4f
error thrown when provided invalid uid
Anwesh1 f5c7b0f
update on error message
Anwesh1 3722fef
first ncbi pytest file
Anwesh1 bd45d4d
first ncbi pytest file
Anwesh1 5f8cd9b
accessing error clearly
Anwesh1 57fa17a
pytest fix as TypeError
Anwesh1 39e065a
Update semantic_search/ncbi.py
Anwesh1 8483e8b
pytest update/error pinpoint
Anwesh1 057d329
error update
Anwesh1 2f00eb1
removing unwanted dependancy
Anwesh1 4cbf5b9
pytests for ncbi.py
Anwesh1 4c6a464
Update tests/test_ncbi.py
Anwesh1 ca4c07b
Update tests/test_ncbi.py
Anwesh1 993cafc
Update tests/test_ncbi.py
Anwesh1 4c04a88
pytest testing ncbi
Anwesh1 b764b39
Update tests/test_ncbi.py
Anwesh1 d527c53
updated pytest ncbi function
Anwesh1 05b8a61
updated pytest ncbi function
Anwesh1 307e959
Update tests/test_ncbi.py
Anwesh1 7231052
:art: Black format tests
JohnGiorgi 1cc907d
:recycle: Replace instances of id with _id
JohnGiorgi 16bad25
added further testing to ncbi
Anwesh1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest | ||
import types | ||
from fastapi.exceptions import HTTPException | ||
|
||
from semantic_search.ncbi import ( | ||
_medline_to_docs, | ||
_safe_request, | ||
_parse_medline, | ||
_get_eutil_records, | ||
uids_to_docs, | ||
Settings, | ||
) | ||
|
||
settings = Settings() | ||
|
||
|
||
def test_invalid_uid_test(): | ||
with pytest.raises(HTTPException): | ||
uid = ["93846392868"] | ||
records = [{"id:": [uid]}] | ||
_medline_to_docs(records) | ||
|
||
|
||
def test_safe_request(): | ||
eutils_params = { | ||
"db": "pubmed", | ||
"id": "9887103", | ||
"retstart": 0, | ||
"retmode": "xml", | ||
"api_key": settings.ncbi_eutils_api_key, | ||
} | ||
url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi" | ||
assert _safe_request(url, "POST", files=eutils_params).status_code == 200 | ||
|
||
|
||
def test_get_eutil_records(): | ||
eutil = "efetch" | ||
id = "9887103" | ||
expected_response = '<generator object parse at 0x7f562cfe9900>' | ||
actual_response = str(_get_eutil_records(eutil,id)) | ||
Anwesh1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert isinstance(_get_eutil_records(eutil, id), types.GeneratorType) | ||
assert actual_response == expected_response | ||
|
||
|
||
def test_parse_medline(): | ||
text = "\nPMID- 9887103\nOWN - NLM\nSTAT- MEDLINE\nDCOM- 19990225\nLR - 20190516\nIS - 0890-9369 (Print)\nIS - 0890-9369 (Linking)\nVI - 13\nIP - 1\nDP - 1999 Jan 1\nTI - The Drosophila activin receptor baboon signals through dSmad2 and controls cell\n proliferation but not patterning during larval development.\nPG - 98-111\nAB - The TGF-beta superfamily of growth and differentiation factors, including\n TGF-beta, Activins and bone morphogenetic proteins (BMPs) play critical roles in \n regulating the development of many organisms. These factors signal through a\n heteromeric complex of type I and II serine/threonine kinase receptors that\n phosphorylate members of the Smad family of transcription factors, thereby\n promoting their nuclear localization. Although components of TGF-beta/Activin\n signaling pathways are well defined in vertebrates, no such pathway has been\n clearly defined in invertebrates. In this study we describe the role of Baboon\n (Babo), a type I Activin receptor previously called Atr-I, in Drosophila\n development and characterize aspects of the Babo intracellular\n signal-transduction pathway. Genetic analysis of babo loss-of-function mutants\n and ectopic activation studies indicate that Babo signaling plays a role in\n regulating cell proliferation. In mammalian cells, activated Babo specifically\n stimulates Smad2-dependent pathways to induce TGF-beta/Activin-responsive\n promoters but not BMP-responsive elements. Furthermore, we identify a new\n Drosophila Smad, termed dSmad2, that is most closely related to vertebrate Smads \n 2 and 3. Activated Babo associates with dSmad2 but not Mad, phosphorylates the\n carboxy-terminal SSXS motif and induces heteromeric complex formation with Medea,\n the Drosophila Smad4 homolog. Our results define a novel Drosophila\n Activin/TGF-beta pathway that is analogous to its vertebrate counterpart and show\n that this pathway functions to promote cellular growth with minimal effects on\n patterning.\nFAU - Brummel, T\nAU - Brummel T\nAD - Department of Molecular Biology and Biochemistry, University of California,\n Irvine, California 92697, USA.\nFAU - Abdollah, S\nAU - Abdollah S\nFAU - Haerry, T E\nAU - Haerry TE\nFAU - Shimell, M J\nAU - Shimell MJ\nFAU - Merriam, J\nAU - Merriam J\nFAU - Raftery, L\nAU - Raftery L\nFAU - Wrana, J L\nAU - Wrana JL\nFAU - O'Connor, M B\nAU - O'Connor MB\nLA - eng\nSI - GENBANK/AF101386\nGR - GM47462/GM/NIGMS NIH HHS/United States\nPT - Journal Article\nPT - Research Support, Non-U.S. Gov't\nPT - Research Support, U.S. Gov't, P.H.S.\nPL - United States\nTA - Genes Dev\nJT - Genes & development\nJID - 8711660\nRN - 0 (Bone Morphogenetic Proteins)\nRN - 0 (DNA-Binding Proteins)\nRN - 0 (Drosophila Proteins)\nRN - 0 (RNA, Messenger)\nRN - 0 (Receptors, Growth Factor)\nRN - 0 (Smad2 Protein)\nRN - 0 (Trans-Activators)\nRN - EC 2.7.11.30 (Activin Receptors)\nRN - EC 2.7.11.30 (Activin Receptors, Type I)\nRN - EC 2.7.11.30 (Babo protein, Drosophila)\nSB - IM\nMH - Activin Receptors\nMH - Activin Receptors, Type I\nMH - Amino Acid Sequence\nMH - Animals\nMH - Bone Morphogenetic Proteins/genetics\nMH - Cell Division\nMH - Cloning, Molecular\nMH - DNA-Binding Proteins/chemistry/*genetics\nMH - Drosophila/*embryology\nMH - Drosophila Proteins\nMH - Gene Expression Regulation, Developmental\nMH - In Situ Hybridization\nMH - Larva/genetics/*growth & development\nMH - Molecular Sequence Data\nMH - Phosphorylation\nMH - RNA, Messenger/genetics\nMH - Receptors, Growth Factor/*genetics/metabolism\nMH - Sequence Alignment\nMH - Sequence Analysis, DNA\nMH - Signal Transduction/*physiology\nMH - Smad2 Protein\nMH - Trans-Activators/chemistry/*genetics\nMH - Wings, Animal/growth & development\nPMC - PMC316373\nEDAT- 1999/01/14 00:00\nMHDA- 1999/01/14 00:01\nCRDT- 1999/01/14 00:00\nPHST- 1999/01/14 00:00 [pubmed]\nPHST- 1999/01/14 00:01 [medline]\nPHST- 1999/01/14 00:00 [entrez]\nAID - 10.1101/gad.13.1.98 [doi]\nPST - ppublish\nSO - Genes Dev. 1999 Jan 1;13(1):98-111. doi: 10.1101/gad.13.1.98.\n" | ||
# checking if generator is returned, need to check integrity of the returned value | ||
assert isinstance(_parse_medline(text), types.GeneratorType) | ||
|
||
|
||
def test_uids_to_docs(): | ||
uids = ["9887103"] | ||
# checking if generator is returned, need to check integrity of the returned value | ||
assert isinstance(uids_to_docs(uids), types.GeneratorType) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct. You need to figure out what the output should be (after casting it to a list) and set
expected_response
to that. This is just the string representation of the object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected list is something like this: (I got it from printing the response of the function)
Now I made that equal to the
expected
. Then I madeactual
equal to what you had said (list(_get_eutil_records(eutil,id))
). However, this still triggers an error on thepytest
test. The error looks like this:This is my updated function:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this means
actual
does not equalexpected
. Eitherexpected
is wrong oractual
is wrong. It is helpful to runpytest
with the-vv
argument to get more information on where they differThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the actual value and replaced it and now it seems to work. I was getting the wrong list in the beginning. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Is it easy to update the other unit tests now?