def test_properties(self): """Test setting options via properties.""" input_file = self.copy_and_mark_for_cleanup("Fasta/f002") cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) cline.revcomp = True cline.pseudo = 20 cline.startmotif = "ACGGGT" self.standard_test_procedure(cline)
def test_properties(self): """Test setting options via properties.""" input_file = self.copy_and_mark_for_cleanup("Fasta/f002") cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) cline.revcomp = True cline.pseudo = 20 cline.startmotif = "ACGGGT" self.standard_test_procedure(cline)
def test_input_filename_with_space(self): """Test an input filename containing a space.""" records = SeqIO.parse("Phylip/hennigian.phy", "phylip") input_file = "temp horses.fasta" with open(input_file, "w") as handle: SeqIO.write(records, handle, "fasta") cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) self.add_file_to_clean(input_file) self.standard_test_procedure(cline)
def test_large_fasta_file(self): """Test a large fasta input file.""" records = list(SeqIO.parse("NBRF/B_nuc.pir", "pir")) input_file = "temp_b_nuc.fasta" with open(input_file, "w") as handle: SeqIO.write(records, handle, "fasta") cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) self.add_file_to_clean(input_file) self.standard_test_procedure(cline)
def test_fasta_one_sequence(self): """Test a fasta input file containing only one sequence.""" record = list(SeqIO.parse("Registry/seqs.fasta", "fasta"))[0] input_file = "seq.fasta" with open(input_file, "w") as handle: SeqIO.write(record, handle, "fasta") cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) self.add_file_to_clean(input_file) self.standard_test_procedure(cline)
def test_output_directory_with_space(self): """Test an output directory containing a space.""" temp_out_dir = "xxmotif test" input_file = self.copy_and_mark_for_cleanup("Fasta/f002") try: XXmotifCommandline(outdir=temp_out_dir, seqfile=input_file) except ValueError: pass else: self.fail("expected ValueError")
def test_invalid_format(self): """Test an input file in an invalid format.""" input_file = self.copy_and_mark_for_cleanup("Medline/pubmed_result1.txt") cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) try: stdout, stderr = cline() except ApplicationError as err: self.assertEqual(err.returncode, 255) else: self.fail("Should have failed, returned:\n%s\n%s" % (stdout, stderr))
def test_empty_file(self): """Test a non-existing input file.""" input_file = "does_not_exist.fasta" self.assertFalse(os.path.isfile(input_file)) cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) try: stdout, stderr = cline() except ApplicationError as err: self.assertEqual(err.returncode, 255) else: self.fail(f"Should have failed, returned:\n{stdout}\n{stderr}")