-
Notifications
You must be signed in to change notification settings - Fork 7
Neo4j Testing (Part 2) #1129
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
Neo4j Testing (Part 2) #1129
Conversation
|
I have a couple tests in the example.js file now, that I would like to receive feedback on! The next couple tests need the Document API, I believe. I would also be interested in hearing about more basic edge cases I can make tests for . Right now all I have to test the basic addNode, addEdge and searchByGeneId functions and I am open to making more low level functions. I do have some functions that I use only for testing in the src/neo4j/test-functions.js file |
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.
Great start. I've attached some suggestions for next steps on the low level functions before moving on.
neo4j-test/example.js
Outdated
| it('Make AKT node', async function () { | ||
| expect(await getNumNodes()).equal(1); | ||
| await addNode('ncbigene:207', 'AKT'); | ||
| expect(await getGeneNameById('ncbigene:207')).equal('AKT'); |
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.
Should probably have helper functions along the lines of getGeneName(node) rather than getGeneNameById().
Things like getGeneName() would be useful generally, whereas getGeneNameById() seems like it's only useful for tests.
neo4j-test/example.js
Outdated
|
|
||
| let mapk6Relationships = mapk6.map(row => { | ||
| return row.get('r'); | ||
| }); |
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.
It would be useful to have some slightly higher level functions here, e.g. searchByGeneID() could directly return an array of edge JSONs.
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.
I've made two functions building off of searchByGeneId:
getNeighbouringNodes( id ): returns the array of nodes connected to/from the specified gene
getInteractions( id ): returns the array of edges/relationships leading from/towards the specified gene
Let me know what you think and please take a look at my other (rather small) amendments when you get the chance! Thank you so much for the feedback
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.
|
Re Docker: You can run both databases with |
| return; | ||
| } | ||
|
|
||
| export async function searchByGeneId(id) { |
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.
These exported functions should have some documentation (https://jsdoc.app/). There's probably an extension that would create most of this?
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.
e.g.
/**
* searchPubmed
* Query the PubMed database for matching UIDs.
*
* @param { String } q The query term
* @param { Object } opts EUTILS ESEARCH options
* @returns { Object } result The search results from PubMed
* @returns { Array } result.searchHits A list of PMIDs
* @returns { Number } result.count The number of searchHits containing PMIDs
* @returns { String } result.query_key See {@link https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch|EUTILS docs }
* @returns { String } result.webenv See {@link https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch|EUTILS docs }
*/
const searchPubmed = ( q, opts ) => eSearchPubmed( q, opts );|
I believe I'm done with this PR for the time being, if you could give it another once-over, I would appreciate it! |
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.
Looks good to merge in - just one question: Is addEdge unique by relationship id? Biofactoid allows one to add an arbitrary number of edges between nodes (identical or otherwise).
Yes, right now the grounding id is the unique UUID every interaction in a factoid document has. I couldn't think of a more suitable one. If it was the two nodes the edge is connected to- then there can only be one edge between those two nodes ever, which does not make sense. That was the other grounding id(s) I was thinking about |
For writing Neo4j Tests (Part 2, after accidentally merging the first one)
Possible Tests (work in progress)