Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClipKit #93

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implemented basic helper class for clipkit and tests
cmorganl committed Jun 3, 2022
commit 5f347729d94996d6e4cf03b49342970615d74319
36 changes: 36 additions & 0 deletions tests/test_clipkit_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
import unittest

from .testing_utils import get_test_data


class MyTestCase(unittest.TestCase):
def setUp(self) -> None:
self.test_fa = get_test_data('PuhA.mfa')
self.output_fa = 'PuhA.clipped.mfa'

def tearDown(self) -> None:
if os.path.isfile(self.output_fa):
os.remove(self.output_fa)

def test_run(self):
from treesapp import clipkit_helper
from clipkit import modes as ck_modes
ck = clipkit_helper.ClipKitHelper(fasta_in=self.test_fa,
mfa_out=self.output_fa,
mode="smart-gap")
ck.run()
self.assertTrue(os.path.isfile(self.output_fa))

ck.mode = ck_modes.TrimmingMode("kpi-smart-gap")
ck.run()
self.assertTrue(os.path.isfile(self.output_fa))

ck.mode = ck_modes.TrimmingMode("kpi")
ck.run()
self.assertTrue(os.path.isfile(self.output_fa))
return


if __name__ == '__main__':
unittest.main()
35 changes: 28 additions & 7 deletions treesapp/clipkit_helper.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
import logging
from clipkit import clipkit
from clipkit import args_processing
import os.path

from clipkit import clipkit as ck
from clipkit import modes as ck_modes

from treesapp import logger


class ClipKitHelper:
CLIPKIT_MODES = {"smart-gap"}

def __init__(self, fasta_in: str, mfa_out: str):
def __init__(self, fasta_in: str, mfa_out=None, mode="smart-gap", gap_prop=0.9):
self.input = fasta_in
if mfa_out is None:
prefix, ext = os.path.splitext(fasta_in)
self.mfa_out = prefix + ".trim" + ext
else:
self.mfa_out = mfa_out

self.logger = logging.getLogger(logger.logger_name())
self.input = ""
self.mfa_out = ""
self.mode = ck_modes.TrimmingMode(mode)
self.gap_prop = gap_prop

self.mode = "smart-gap"
self.ff_in = "fasta"
self.ff_out = "fasta"
return

def run(self):
# clipkit.execute()

ck.execute(input_file=self.input,
input_file_format=self.ff_in,
output_file=self.mfa_out,
output_file_format=self.ff_out,
gaps=self.gap_prop,
complement=False,
mode=self.mode,
use_log=False)
return

def summarise_trimming(self):
return