-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PlanemoLintBear.py: Add linter bear for planemo
Added a linter bear for planemo lint Used `planemo lint` command Closes #1321
- Loading branch information
Showing
6 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import shlex | ||
|
||
from coalib.bearlib.abstractions.Linter import linter | ||
from dependency_management.requirements.PipRequirement import PipRequirement | ||
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY | ||
from coalib.settings.Setting import typed_list | ||
|
||
|
||
@linter(executable='planemo', | ||
output_format='regex', | ||
output_regex=r'..\s(?P<severity>\w*:)(?P<message>.*)', | ||
severity_map={'WARNING:': RESULT_SEVERITY.MAJOR, | ||
'CHECK:': RESULT_SEVERITY.NORMAL, | ||
'INFO:': RESULT_SEVERITY.INFO}) | ||
class PlanemoLintBear: | ||
""" | ||
Checks the code with pylint. This will run pylint over each file | ||
separately. | ||
""" | ||
LANGUAGES = {'xml'} | ||
REQUIREMENTS = {PipRequirement('planemo', '0.36')} | ||
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_DETECT = {'Syntax'} | ||
|
||
@staticmethod | ||
def create_arguments(filename, file, config_file,): | ||
""" | ||
:param pylint_disable: Disable the message, report, category or | ||
checker with the given id(s). | ||
:param pylint_enable: Enable the message, report, category or | ||
checker with the given id(s). | ||
:param pylint_cli_options: Any command line options you wish to be | ||
passed to pylint. | ||
:param pylint_rcfile: The rcfile for PyLint. | ||
""" | ||
args = ('lint',) | ||
|
||
return args + (filename,) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ pytest-timeout~=1.2 | |
pytest-xdist~=1.15 | ||
requests_mock~=0.7.0 | ||
wheel~=0.29 | ||
planemo~=0.36 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import re | ||
from queue import Queue | ||
from shutil import which | ||
from unittest.case import skipIf | ||
|
||
from bears.planemo.PlanemoLintBear import PlanemoLintBear | ||
from coalib.testing.LocalBearTestHelper import LocalBearTestHelper | ||
from coalib.settings.Section import Section | ||
from coalib.settings.Setting import Setting | ||
|
||
|
||
@skipIf(which('planemo') is None, 'Planemo is not installed') | ||
class PlanemoLintBearTest(LocalBearTestHelper): | ||
|
||
def setUp(self): | ||
self.section = Section('test section') | ||
self.uut = PlanemoLintBear(self.section, Queue()) | ||
self.test_file = os.path.join(os.path.dirname(__file__), | ||
'test_files', | ||
'planemolint_test.xml') | ||
|
||
def test_run(self): | ||
self.check_validity( | ||
self.uut, | ||
[], # Doesn't matter, planemo lint will parse the file | ||
self.test_file, | ||
valid=False) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<tool id="random_lines1" name="Select random lines" version="2.0.1"> | ||
<description>from a file</description> | ||
<command interpreter="python">random_lines_two_pass.py "${input}" "${out_file1}" "${num_lines}" | ||
#if str( $seed_source.seed_source_selector ) == "set_seed": | ||
--seed "${seed_source.seed}" | ||
#end if | ||
</command> | ||
<inputs> | ||
<param name="num_lines" size="5" type="integer" value="1" label="Randomly select" help="lines"/> | ||
<param format="txt" name="input" type="data" label="from"/> | ||
<conditional name="seed_source"> | ||
<param name="seed_source_selector" type="select" label="Set a random seed"> | ||
<option value="no_seed" selected="True">Don't set seed</option> | ||
<option value="set_seed">Set seed</option> | ||
</param> | ||
<when value="no_seed"> | ||
<!-- Do nothing here --> | ||
</when> | ||
<when value="set_seed"> | ||
<param name="seed" type="text" label="Random seed" /> | ||
</when> | ||
</conditional> | ||
</inputs> | ||
<outputs> | ||
<data format="input" name="out_file1" metadata_source="input"/> | ||
</outputs> | ||
<tests> | ||
<test> | ||
<param name="num_lines" value="65"/> | ||
<param name="input" value="1.bed"/> | ||
<param name="seed_source_selector" value="no_seed"/> | ||
<output name="out_file1" file="1.bed"/> | ||
</test> | ||
<test> | ||
<param name="num_lines" value="1"/> | ||
<param name="input" value="1.bed"/> | ||
<param name="seed_source_selector" value="set_seed"/> | ||
<param name="seed" value="asdf"/> | ||
<output name="out_file1" file="1_bed_random_lines_1_seed_asdf_out.bed"/> | ||
</test> | ||
</tests> | ||
<help> | ||
|
||
**What it does** | ||
|
||
This tool selects N random lines from a file, with no repeats, and preserving ordering. | ||
|
||
----- | ||
|
||
**Example** | ||
|
||
Input File:: | ||
|
||
chr7 56632 56652 D17003_CTCF_R6 310 + | ||
chr7 56736 56756 D17003_CTCF_R7 354 + | ||
chr7 56761 56781 D17003_CTCF_R4 220 + | ||
chr7 56772 56792 D17003_CTCF_R7 372 + | ||
chr7 56775 56795 D17003_CTCF_R4 207 + | ||
|
||
Selecting 2 random lines might return this:: | ||
|
||
chr7 56736 56756 D17003_CTCF_R7 354 + | ||
chr7 56775 56795 D17003_CTCF_R4 207 + | ||
|
||
</help> | ||
</tool> |