Skip to content

Commit

Permalink
test: add org param tests
Browse files Browse the repository at this point in the history
  • Loading branch information
balajtimate committed Oct 31, 2023
1 parent 52eafa8 commit 5fde74a
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Log.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
STAR version=2.7.10b
STAR compilation time,server,dir=2022-11-01T09:53:26-04:00 :/home/dobin/data/STAR/STARcode/STAR.master/source
STAR git: On branch master ; commit c6f8efc2c7043ef83bf8b0d9bed36bbb6b9b1133 ; diff files: CHANGES.md
##### Command Line:
STAR --runMode genomeGenerate --genomeSAindexNbases 5 --genomeChrBinNbits 18 --runThreadN 1 --genomeDir /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/index --genomeFastaFiles /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/invalid
##### Initial USER parameters from Command Line:
###### All USER parameters from Command Line:
runMode genomeGenerate ~RE-DEFINED
genomeSAindexNbases 5 ~RE-DEFINED
genomeChrBinNbits 18 ~RE-DEFINED
runThreadN 1 ~RE-DEFINED
genomeDir /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/index ~RE-DEFINED
genomeFastaFiles /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/invalid ~RE-DEFINED
##### Finished reading parameters from all sources

##### Final user re-defined parameters-----------------:
runMode genomeGenerate
runThreadN 1
genomeDir /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/index
genomeFastaFiles /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/invalid
genomeSAindexNbases 5
genomeChrBinNbits 18

-------------------------------
##### Final effective command line:
STAR --runMode genomeGenerate --runThreadN 1 --genomeDir /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/index --genomeFastaFiles /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/invalid --genomeSAindexNbases 5 --genomeChrBinNbits 18
----------------------------------------

Number of fastq files for each mate = 1
ParametersSolo: --soloCellFilterType CellRanger2.2 filtering parameters: 3000 0.99 10
Finished loading and checking parameters
--genomeDir directory exists and will be overwritten: /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/index/
!!!!! WARNING: Could not move Log.out file from ./Log.out into /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/index/Log.out. Will keep ./Log.out

Oct 31 16:40:53 ... starting to generate Genome files

EXITING because of INPUT ERROR: could not open genomeFastaFile: /scratch/pytest-of-balajt0000/pytest-29/test_create_star_index_star_pr0/invalid

Oct 31 16:40:53 ...... FATAL ERROR, exiting
79 changes: 79 additions & 0 deletions tests/test_get_library_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,52 @@ def test_evaluate_min_freq_ratio(self, tmpdir):
file_2=Source()
)

def test_evaluate_org_id_not_none(self):
"""Test when self.org_id is not None."""
CONFIG.args.org_id = 7227 # An example taxon ID
CONFIG.args.t_file_processed = FILE_TRANSCRIPTS
test_instance = GetLibSource(config=CONFIG)
result = test_instance.evaluate()

assert result.file_1.taxon_id == 7227
assert result.file_1.short_name == "dmelanogaster"

def test_evaluate_org_id_none_with_path_2(self, tmpdir, monkeypatch):
"""Test when self.org_id is None and self.paths[1] is not None."""
CONFIG.args.org_id = None
CONFIG.args.path_1_processed = FILE_MATE_1
CONFIG.args.path_2_processed = FILE_MATE_2
CONFIG.args.t_file_processed = FILE_TRANSCRIPTS
CONFIG.args.tmp_dir = tmpdir
CONFIG.args.out_dir = tmpdir
test_instance = GetLibSource(config=CONFIG)

# Mock the get_source method to return a specific result
monkeypatch.setattr(
'htsinfer.get_library_source.GetLibSource.get_source',
lambda *args, **kwargs: SOURCE_HUMAN,
)

result = test_instance.evaluate()

assert result.file_2.taxon_id == SOURCE_HUMAN.taxon_id
assert result.file_2.short_name == SOURCE_HUMAN.short_name

def test_evaluate_org_id_not_none_with_path_2(self, tmpdir):
"""Test when self.org_id is not None and self.paths[1] is not None."""
CONFIG.args.org_id = 7227
CONFIG.args.path_1_processed = FILE_MATE_1
CONFIG.args.path_2_processed = FILE_MATE_2
CONFIG.args.t_file_processed = FILE_TRANSCRIPTS
CONFIG.args.tmp_dir = tmpdir
CONFIG.args.out_dir = tmpdir
test_instance = GetLibSource(config=CONFIG)

result = test_instance.evaluate()

assert result.file_2.taxon_id == 7227
assert result.file_2.short_name == "dmelanogaster"

def test_create_kallisto_index_problem(self, tmpdir):
"""Pass invalid file as transcripts.fasta file
to simulate KallistoProblem."""
Expand All @@ -276,3 +322,36 @@ def test_create_kallisto_index_problem(self, tmpdir):
test_instance = GetLibSource(config=CONFIG)
with pytest.raises(KallistoProblem):
test_instance.create_kallisto_index()

def test_get_organism_name_found(self):
"""Test the function when the taxon_id
is found in the organism dictionary."""
CONFIG.args.t_file_processed = FILE_TRANSCRIPTS
test_instance = GetLibSource(config=CONFIG)
taxon_id = 7227
result = test_instance.get_organism_name(
taxon_id, CONFIG.args.t_file_processed
)
assert result == "dmelanogaster"

def test_get_organism_name_not_found(self):
"""Test the function when the taxon_id
is not found in the organism dictionary."""
CONFIG.args.t_file_processed = FILE_TRANSCRIPTS
test_instance = GetLibSource(config=CONFIG)
taxon_id = 12345 # A tax ID that doesn't exist in transcripts
result = test_instance.get_organism_name(
taxon_id, CONFIG.args.t_file_processed
)
assert result is None

def test_get_organism_name_file_problem(self):
"""Test the function when there's a
file problem while processing the FASTA file."""
CONFIG.args.t_file_processed = FILE_DUMMY
test_instance = GetLibSource(config=CONFIG)
taxon_id = 7227
with pytest.raises(FileProblem):
test_instance.get_organism_name(
taxon_id, CONFIG.args.t_file_processed
)

0 comments on commit 5fde74a

Please sign in to comment.