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_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: cline = 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, err: self.assertEqual(err.returncode, 255)
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, err: self.assertEqual(err.returncode, 255)
def test_input_filename_with_space(self): """Test an input filename containing a space.""" input_file = "temp horses.fasta" handle = open(input_file, "w") SeqIO.write(SeqIO.parse("Phylip/hennigian.phy", "phylip"), handle, "fasta") handle.close() 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.""" input_file = "temp_b_nuc.fasta" handle = open(input_file, "w") records = list(SeqIO.parse("NBRF/B_nuc.pir", "pir")) SeqIO.write(records, handle, "fasta") handle.close() del handle, records 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.""" input_file = "seq.fasta" handle = open(input_file, "w") record = list(SeqIO.parse("Registry/seqs.fasta", "fasta"))[0] SeqIO.write(record, handle, "fasta") handle.close() del handle, record cline = XXmotifCommandline(outdir=self.out_dir, seqfile=input_file) self.add_file_to_clean(input_file) self.standard_test_procedure(cline)