Skip to content

Conversation

@lindajiawenli
Copy link
Contributor

@lindajiawenli lindajiawenli commented Feb 21, 2023

For writing Neo4j Tests (Part 2, after accidentally merging the first one)

Possible Tests (work in progress)

  • 1. Verify DB connection with Neo4j driver
  • 2. Verify 1 node is being made correctly
  • 3. Verify 1 edge is being made correctly
  • 4. Verify that attempting to make a duplicate node fails
  • 5. Verify that attempting to make a duplicate edge fails
  • 6. Verify that searchByGeneId function/read database is correct for an non-existing node
  • 7. Verify that searchByGeneId function/read database is correct for an existing node
  • 8. Verify that all the nodes in a document are made (no duplication or missing nodes)
  • 9. Verify that all the edges in a document are made (no duplication or missing nodes)
  • 10. Verify that all the nodes in multiple documents are made (no duplication or missing nodes)
  • 11. Verify that all the nodes in multiple documents are made (no duplication or missing nodes)
  • 12. Verify that a node deletion is successful (function exists for testing, not sure if it is useful in for our user)

@lindajiawenli lindajiawenli self-assigned this Feb 21, 2023
@lindajiawenli
Copy link
Contributor Author

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

@lindajiawenli lindajiawenli linked an issue Feb 22, 2023 that may be closed by this pull request
Copy link
Member

@maxkfranz maxkfranz left a 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.

it('Make AKT node', async function () {
expect(await getNumNodes()).equal(1);
await addNode('ncbigene:207', 'AKT');
expect(await getGeneNameById('ncbigene:207')).equal('AKT');
Copy link
Member

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.


let mapk6Relationships = mapk6.map(row => {
return row.get('r');
});
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jvwong
Copy link
Member

jvwong commented Feb 23, 2023

Re Docker: You can run both databases with docker-compose up -d. The data should persist between runs as it is stashed in a 'volume' somewhere on your machine.

return;
}

export async function searchByGeneId(id) {
Copy link
Member

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?

Copy link
Member

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 );

@lindajiawenli
Copy link
Contributor Author

I believe I'm done with this PR for the time being, if you could give it another once-over, I would appreciate it!

Copy link
Member

@jvwong jvwong left a 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).

@lindajiawenli
Copy link
Contributor Author

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

@lindajiawenli lindajiawenli merged commit 13f061f into unstable Feb 27, 2023
@lindajiawenli lindajiawenli deleted the testing-neo4j-v2 branch February 27, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Neo4J tests

4 participants