Skip to content

Commit

Permalink
PR #1 tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
veghp committed Sep 14, 2020
1 parent 21bb4ce commit 8fee036
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Binary file added tests/data/test_protein_seq.docx
Binary file not shown.
25 changes: 25 additions & 0 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


example_path = os.path.join("tests", "data", "test_sample.docx")
protein_path = os.path.join("tests", "data", "test_protein_seq.docx")


def test_crazydocparser(tmpdir):
Expand Down Expand Up @@ -33,3 +34,27 @@ def test_crazydocparser(tmpdir):
ax.set_title(record.id)
filepath = os.path.join(str(tmpdir), "%s.png" % record.id)
ax.figure.savefig(filepath, bbox_inches="tight")

# PROTEIN SEQUENCES:
biopython_records = parser.parse_doc_file(protein_path, is_protein=True)
record_features = [
[(f.location.start, f.location.end, f.qualifiers) for f in record.features]
for record in biopython_records
]

# Test for names with "/":
records_to_genbank(biopython_records, path=str(tmpdir), is_protein=True)
assert os.path.exists(os.path.join(tmpdir, "Protein sequence 2-a.gp"))
# Test truncation of LOCUS names to 20 characters in Genbank file:
with open(os.path.join(tmpdir, "Protein sequence with a long name 1.gp")) as f:
first_line = f.readline()
first_line.split()[1] == "Protein_sequence_wit"

sketcher = CrazydocSketcher()
for record in biopython_records:
sketch = sketcher.translate_record(record)
ax, _ = sketch.plot()
ax.set_title(record.id)
filename = record.id.replace("/", "-") + ".png"
filepath = os.path.join(str(tmpdir), filename)
ax.figure.savefig(filepath, bbox_inches="tight")

0 comments on commit 8fee036

Please sign in to comment.