Skip to content

Commit

Permalink
[re/factor] v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocoParrot committed Sep 14, 2021
1 parent 3d7bbb9 commit 7abe67f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 666 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name="orffinder",
version="1.4",
version="1.5",
author="ChocoParrot",
author_email="[email protected]",
description="ORFFinder API.",
Expand All @@ -23,7 +23,7 @@
"Operating System :: OS Independent",
),
install_requires=[
"biopython==1.79"
"biopython>=1.79"
],
scripts=[
"src/cline_tools/orffinder-to-gtf",
Expand Down
238 changes: 0 additions & 238 deletions src/cline_tools/gene.fasta

This file was deleted.

63 changes: 63 additions & 0 deletions src/cline_tools/orffinder-to-gff3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python

import sys
import os
from Bio import SeqIO
from orffinder import orffinder

arguments = sys.argv + [""]
classed_arguments = {"orf_size": "75", "max_orfs_per_sequence": "-1", "remove_nested": "False", "trim_trailing": "False", "infmt": "fasta", "attr_name": "ORF_"}

try:
for i in range(len(arguments)):

argument = arguments[i]

if argument.startswith("-"):

classed_arguments[argument[1:]] = arguments[i + 1]

if "h" in classed_arguments.keys():
help_output = open("help_pages/orffinder-to-gtf.txt", "r").read()
print(help_output)
os._exit(1)

sequences = SeqIO.parse(classed_arguments["in"], classed_arguments["infmt"])

orf_size = int(classed_arguments["orf_size"])
remove_nested = classed_arguments["remove_nested"] == "True"
trim_trailing = classed_arguments["trim_trailing"] == "True"
attr_name = classed_arguments["attr_name"]
max_orfs_per_sequence = int(classed_arguments["max_orfs_per_sequence"])

output = [["##gff-version 3"]]
index = int()

for sequence in sequences:

seqname = sequence.description
orfs = orffinder.getORFs(sequence, minimum_length=orf_size, trim_trailing=trim_trailing, remove_nested=remove_nested)

local_index = int()
for orf in orfs:

index += 1
local_index += 1
output.append([seqname, "ORFFinder Python", "ORF", str(orf["start"]), str(orf["end"]), ".", orf["sense"], str(orf["frame"] - 1), "orf_id=" + attr_name + str(index) + ";"])

if local_index >= max_orfs_per_sequence and max_orfs_per_sequence != -1:
break


full_output = "\n".join(["\t".join(x) for x in output])

if "out" not in classed_arguments.keys():

print(full_output)

else:

open(classed_arguments["out"], "w+").write(full_output)

except:
print("USAGE\n orffinder-to-gff3 [-in input] [-infmt format] [-out output] [-orf_size int]\n [-remove_nested boolean] [-trim_trailing boolean] [-max_orfs_per_sequence int]\n [-attr_name string]\n\nDESCRIPTION\n ORFFinder Python v1.5\n\nUse '-help' to print detailed descriptions of command line arguments\n========================================================================")
Loading

0 comments on commit 7abe67f

Please sign in to comment.