def test_write_fasta_file(self, seqprop_with_i, tmpdir, test_files_outputs, seq_record_example):
"""Test that everything behaves properly when writing the SeqProp to a FASTA file"""
# Add dummy annotations to the SeqProp - check to see if they stay in the SeqProp even after Seq is written
seqprop_with_i.letter_annotations.update({'test_la_key': 'X' * len(seqprop_with_i.seq)})
seqprop_with_i.features.append(SeqFeature(FeatureLocation(1, 3)))
# Write the Seq to a FASTA file
outpath = tmpdir.join('test_seqprop_with_i_write_fasta_file.fasta').strpath
seqprop_with_i.write_fasta_file(outfile=outpath, force_rerun=True)
# Test that the file was written
assert op.exists(outpath)
assert op.getsize(outpath) > 0
# Test that file paths are correct
assert seqprop_with_i.sequence_path == outpath
assert seqprop_with_i.sequence_file == 'test_seqprop_with_i_write_fasta_file.fasta'
assert seqprop_with_i.sequence_dir == tmpdir
# Once a file is written, the annotations should not be lost, even though the sequence now
# loads from the written file as a Seq
assert seqprop_with_i.description == seq_record_example.description
assert seqprop_with_i.annotations == seq_record_example.annotations
assert seqprop_with_i.letter_annotations == {'test_la_key': 'X' * len(seq_record_example.seq)}
assert len(seqprop_with_i.features) == 1
# Test that sequence cannot be changed
with pytest.raises(ValueError):
seqprop_with_i.seq = 'THISWILLNOTBETHESEQ'
assert seqprop_with_i.seq == seq_record_example.seq
评论列表
文章目录