stajichlab / RelocaTE3

ReLocaTE code for identifying Transposons (TE) in genomes using re-sequencing data
MIT License
2 stars 1 forks source link

Setup testing environment #4

Open hyphaltip opened 4 days ago

hyphaltip commented 4 days ago

We need to setup some basic testing env and runs so we understand how to structure the unit test files and datasets for this.

@chtsai0105 I am hoping you can help us get some of the basics started so we have examples of how to write this. We want to build unit tests around the different functions but also simple unit tests to show that dependencies are working.

So far we could use python #3 minimap as well as pysam for some of the steps we need to do instead of installing samtools and minimap2. I wonder if the python bwa mapper works - though I'd want to use a standard version of the software if possible as getting versions correct may vary the results. eg https://github.com/nanoporetech/bwapy

chtsai0105 commented 4 days ago

Unit test examples have been added in 2f1779f. I'm using pytest to do it so you need to install pytest first:

mamda install pytest

and then go to the root folder of the project, run:

pytest
chtsai0105 commented 4 days ago

Note that the unit test is used to test function that do a single action. E.g. the align function inside pipeline.py.

However in a pipeline tool you usually need to combine several functions into a pipeline function. In this case I use pytest.monkeypatch and corresponding mockreturn function to avoid redo the unit test that have already done. E.g. in the test_main_align test function of the tests/main_test.py I used monkeypatch to temporarily replace the align function imported in __main__.py to a mockreturn function, which simply print the keyword arguments and do nothing. By doing so I can test the main function inside __main__.py without truly run the codes.

hyphaltip commented 4 days ago

Great. I started a test too mostly as a well test. Let’s see how I it all works.

Sent from Gmail Mobile @.*** Jason Stajich - UC Riverside http://lab.stajich.org

On Wed, Jun 26, 2024 at 4:27 PM Cheng-Hung Tsai @.***> wrote:

Note that the unit test is used to test function that do a single action. E.g. the align function inside pipeline.py.

However in a pipeline tool you usually need to combine several functions into a pipeline function. In this case I use pytest.monkeypatch and corresponding mockreturn function to avoid redo the unit test that have already done. E.g. in the test_main_align test function of the tests/main_test.py I used monkeypatch to temporarily replace the align function imported in main.py to a mockreturn function, which simply print the keyword arguments and do nothing. By doing so I can test the main function inside main.py without truly run the codes.

— Reply to this email directly, view it on GitHub https://github.com/stajichlab/RelocaTE3/issues/4#issuecomment-2192782905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAL5O5OLDU6D263JT63GR3ZJNE6JAVCNFSM6AAAAABJ6R5GIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJSG44DEOJQGU . You are receiving this because you authored the thread.Message ID: @.***>