def test_nucleotide_search_unaligned_reads_output_blast_format(self): """ Test the unaligned reads and the store alignments Test with a bowtie2/sam output file Test the aligned reads file created is of the blastm8 format """ # create a set of alignments alignments = store.Alignments() unaligned_reads_store = store.Reads() config.file_basename = "TEST" # read in the aligned and unaligned reads [unaligned_reads_file_fasta, reduced_aligned_reads_file ] = nucleotide.unaligned_reads(cfg.sam_file_annotations, alignments, unaligned_reads_store, keep_sam=True) # test file is of the blastm8 format file_format = utilities.determine_file_format( reduced_aligned_reads_file) # remove temp files utils.remove_temp_file(unaligned_reads_file_fasta) utils.remove_temp_file(reduced_aligned_reads_file) self.assertEqual(file_format, "blastm8")
def test_determine_file_format_fastq_gzip(self): """ Test the determine_file_format function with a fastq file that is gzipped """ # create a small gzipped fastq file # read in the small fastq file file_handle = open(cfg.small_fastq_file, "rt") # create a temp file file_out, gzip_fastq_file = tempfile.mkstemp(suffix=".gz") os.close(file_out) # write the gzipped file file_handle_gzip = gzip.open(gzip_fastq_file, "wt") shutil.copyfileobj(file_handle, file_handle_gzip) file_handle.close() file_handle_gzip.close() format = utilities.determine_file_format(gzip_fastq_file) # remove the temp gzipped file utils.remove_temp_file(gzip_fastq_file) self.assertEqual(format, "fastq.gz")
def test_nucleotide_search_unaligned_reads_output_fasta_format(self): """ Test the unaligned reads and the store alignments Test with a bowtie2/sam output file Test output file is of fasta format Test sam file is not removed """ # create a set of alignments alignments = store.Alignments() unaligned_reads_store = store.Reads() # read in the aligned and unaligned reads [unaligned_reads_file_fasta, reduced_aligned_reads_file ] = nucleotide.unaligned_reads(cfg.sam_file_unaligned_reads, alignments, unaligned_reads_store, keep_sam=True) # check for fasta output file format file_format = utilities.determine_file_format( unaligned_reads_file_fasta) self.assertEqual("fasta", file_format) # remove temp files utils.remove_temp_file(unaligned_reads_file_fasta) utils.remove_temp_file(reduced_aligned_reads_file)
def test_determine_file_format_genetable(self): """ Test the determine_file_format function with a gene table tsv file """ format = utilities.determine_file_format(cfg.genetable_file) self.assertEqual(format, "genetable")
def test_determine_file_format_biom(self): """ Test the determine_file_format function with a biom file """ format = utilities.determine_file_format(cfg.biom_file) self.assertEqual(format, "biom")
def test_determine_file_format_sam_without_header(self): """ Test the determine_file_format function with a sam file without header """ format = utilities.determine_file_format(cfg.sam_file_without_header) self.assertEqual(format, "sam")
def test_determine_file_format_fastq(self): """ Test the determine_file_format function with a fastq file """ format = utilities.determine_file_format(cfg.small_fastq_file) self.assertEqual(format, "fastq")
def test_determine_file_format_rapsearch2_without_header(self): """ Test the determine_file_format function with a rapsearch2 output file without the standard header format """ format = utilities.determine_file_format( cfg.rapsearch2_output_file_without_header) self.assertEqual(format, "blastm8")