Skip to content

Commit fdb1b51

Browse files
committed
Add --cite_url to tool_init.
Allows bootstrapping some of the bibtex boilerplate.
1 parent 6b8a67b commit fdb1b51

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

planemo/commands/cmd_tool_init.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@
165165
help=("Supply a DOI (http://www.doi.org/) easing citation of the tool "
166166
"for Galxy users (e.g. 10.1101/014043).")
167167
)
168+
@click.option(
169+
"--cite_url",
170+
type=click.STRING,
171+
default=None,
172+
multiple=True,
173+
prompt=False,
174+
help=("Supply a URL for citation.")
175+
)
168176
@click.option(
169177
"--test_case",
170178
is_flag=True,

planemo/tool_builder.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
<citations>
105105
{%- for single_doi in doi %}
106106
<citation type="doi">{{ single_doi }}</citation>
107+
{%- endfor %}
108+
{%- for bibtex_citation in bibtex_citations %}
109+
<citation type="bibtex">{{ bibtex_citation }}</citation>
107110
{%- endfor %}
108111
<yield />
109112
</citations>
@@ -126,6 +129,12 @@ def build(**kwds):
126129

127130
_handle_help(kwds)
128131

132+
# process raw cite urls
133+
cite_urls = kwds.get("cite_url", [])
134+
del kwds["cite_url"]
135+
citations = map(UrlCitation, cite_urls)
136+
kwds["bibtex_citations"] = citations
137+
129138
# process raw inputs
130139
inputs = kwds.get("input", [])
131140
del kwds["input"]
@@ -274,6 +283,41 @@ def _find_command(kwds):
274283
return command
275284

276285

286+
class UrlCitation(object):
287+
288+
def __init__(self, url):
289+
self.url = url
290+
291+
def __str__(self):
292+
if "github.com" in self.url:
293+
return self._github_str()
294+
else:
295+
return self._url_str()
296+
297+
def _github_str(self):
298+
url = self.url
299+
title = url.split("/")[-1]
300+
return '''
301+
@misc{github%s,
302+
author = {LastTODO, FirstTODO},
303+
year = {TODO},
304+
title = {%s},
305+
publisher = {GitHub},
306+
journal = {GitHub repository},
307+
url = {%s},
308+
}''' % (title, title, url)
309+
310+
def _url_str(self):
311+
url = self.url
312+
return '''
313+
@misc{renameTODO,
314+
author = {LastTODO, FirstTODO},
315+
year = {TODO},
316+
title = {TODO},
317+
url = {%s},
318+
}''' % (url)
319+
320+
277321
class ToolDescription(object):
278322

279323
def __init__(self, contents, macro_contents, test_files):

tests/test_build_and_lint.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def _init_command(test_case=True, help_text=True, doi=True, macros=False):
5252
command.extend(["--help_text", "The help text."])
5353
if doi:
5454
command.extend(["--doi", "10.1101/014043"])
55+
command.extend(["--cite_url", "https://github.com/ekg/vcflib"])
56+
command.extend(["--cite_url", "http://wiki.hpc.ufl.edu/doc/Seqtk"])
5557
if macros:
5658
command.append("--macros")
5759
return command

0 commit comments

Comments
 (0)