• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Edinburgh-Genome-Foundry / DnaChisel / 14261706617

04 Apr 2025 08:54AM UTC coverage: 89.721% (-0.8%) from 90.508%
14261706617

push

github

veghp
Fix cli interface

0 of 3 new or added lines in 1 file covered. (0.0%)

2994 of 3337 relevant lines covered (89.72%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/dnachisel/cli.py
1
#!/usr/bin/env python
2

3
"""
4
DNA Chisel Command Line Interface
5

6
Usage:
7
  dnachisel <source> <target> [--circular] [--mute] [--with_sequence_edits]
8

9
Where ``source`` is a fasta or Genbank file, and target can be one of:
10
- A folder name or a zip name (extension .zip). In this case a complete report
11
  along with the sequence will be generated.
12
- A Genbank file. In this case, only the optimized sequence file is created.
13
  The with_sequence_edits option specifies that edits are also annotated in the
14
  Genbank file. Note that the filename must end with '.gb'.
15

16
Note: this CLI will be developed on a per-request basis, so don't hesitate to
17
ask for more handles and options on Github
18
(https://github.com/Edinburgh-Genome-Foundry/DnaChisel/issues)
19

20
Example to output the result to a genbank:
21

22
>>> dnachisel annotated_record.gb optimized_record.gb
23

24
Example to output the result to a folder:
25

26
>>> dnachisel annotated_record.gb optimization_report/
27

28
Example to output the result to a zip archive:
29

30
>>> dnachisel annotated_record.gb optimization_report.zip
31
"""
32

33

34
def main():
×
NEW
35
    import os
×
NEW
36
    from docopt import docopt
×
NEW
37
    from dnachisel import DnaOptimizationProblem, CircularDnaOptimizationProblem
×
38

39
    params = docopt(__doc__)
×
40
    source, target = params["<source>"], params["<target>"]
×
41

42
    # VERBOSE PRINT
43
    def verbose_print(*args):
×
44
        if not params["--mute"]:
×
45
            print(*args)
×
46

47
    # PARSE THE CIRCULARITY
48

49
    if params["--circular"]:
×
50
        problem_class = CircularDnaOptimizationProblem
×
51
    else:
52
        problem_class = DnaOptimizationProblem
×
53
    problem = problem_class.from_record(
×
54
        source, logger=None if params["--mute"] else "bar"
55
    )
56
    problem.max_random_iters = 10000
×
57
    verbose_print(
×
58
        "\n\nBefore optimization:\n\n",
59
        problem.constraints_text_summary(),
60
        problem.objectives_text_summary(),
61
    )
62

63
    if target.lower().endswith(".gb"):  # save genbank
×
64
        if params["--with_sequence_edits"]:
×
65
            annotate_edits = True
×
66
        else:
67
            annotate_edits = False
×
68
        verbose_print("Resolving Constraints...")
×
69
        problem.resolve_constraints()
×
70
        verbose_print("Optimizing...")
×
71
        problem.optimize()
×
72
        problem.to_record(filepath=target, with_sequence_edits=annotate_edits)
×
73

74
    else:  # save into zip or folder
75
        project_name = os.path.basename(source)
×
76
        problem.optimize_with_report(
×
77
            target, project_name=project_name, file_path=source
78
        )
79

80
    verbose_print(
×
81
        "\n\nAfter optimization:\n\n",
82
        problem.constraints_text_summary(),
83
        problem.objectives_text_summary(),
84
        "\n\n",
85
        "Result written to %s" % target,
86
    )
87

88

89
if __name__ == "__main__":
×
90
    main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc