Skip to content

Commit

Permalink
Merge branch 'staramr_add' of https://github.com/clsiguret/tools-iuc
Browse files Browse the repository at this point in the history
…into staramr_add
  • Loading branch information
hugolefeuvre committed Dec 4, 2024
2 parents 2d20089 + a397cb2 commit e84dae7
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,21 @@ def download_untar_store(url, tmp_path, dest_path):
tar = tarfile.open(tarfile_path)
tar.extractall(extract_path)

print(f"Content of folder: {extract_path}", os.listdir(extract_path))

# case for mapseq v6: all DB files are directly in the tar.gz file
# remove the VERSION.txt file since the tool can only handle on .txt file in the DB
if len(list(os.listdir(extract_path))) > 1:
print("More then one folder in zipped file, aborting !")
print(f"Found multiple files in {extract_path}. Copy the content.")
print(f"Copy data to {dest_path}")
version_file_path = os.path.join(extract_path, "VERSION.txt")
os.remove(version_file_path)
shutil.copytree(extract_path, dest_path)
print("Done !")

# case for mapseq v5: all files are in a subfolder in the tar.gz file
else:
print(f"Found a folder in {extract_path}. Copy the content of the folder.")
for folder in os.listdir(extract_path):
folder_path = os.path.join(extract_path, folder)

Expand All @@ -69,8 +81,12 @@ def main():
# Parse Command Line
parser = argparse.ArgumentParser(description="Create data manager JSON.")
parser.add_argument("--out", dest="output", action="store", help="JSON filename")
parser.add_argument("--version", dest="version", action="store", help="Version of the DB")
parser.add_argument("--database-type", dest="db_type", action="store", help="Db type")
parser.add_argument(
"--version", dest="version", action="store", help="Version of the DB"
)
parser.add_argument(
"--database-type", dest="db_type", action="store", help="Db type"
)
parser.add_argument(
"--test",
action="store_true",
Expand All @@ -85,8 +101,6 @@ def main():
with open(args.output) as fh:
params = json.load(fh)

print(params)

workdir = params["output_data"][0]["extra_files_path"]
os.mkdir(workdir)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</command>
<inputs>
<!-- <param name="test_data_manager" type="hidden" /> -->
<param name="test_data_manager_v5" type="boolean" truevalue="--test" falsevalue="" checked="False" label="Download minimal test DB and create mock data table entry." />
<param name="test_data_manager_v6" type="boolean" truevalue="--test" falsevalue="" checked="False" label="Download minimal test DB and create mock data table entry." />
<param name="test_data_manager_v5" type="boolean" truevalue="--test" falsevalue="" checked="False" label="Download minimal test DB and create mock data table entry for v5." />
<param name="test_data_manager_v6" type="boolean" truevalue="--test" falsevalue="" checked="False" label="Download minimal test DB and create mock data table entry for v6." />

<param name="database_type" type="select" multiple="false" label="Database Type">
<option value="mgnify_v6_lsu">MGnify LSU (v6.0)</option>
Expand Down
2 changes: 1 addition & 1 deletion tools/cojac/cooc_pubmut.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</macros>
<expand macro="biotools"/>
<expand macro="requirements">
<requirement type="package" version="3.2">pandoc</requirement>
<requirement type="package" version="3.5">pandoc</requirement>
<requirement type="package" version="6.3.0">gmp</requirement>
</expand>
<expand macro="version"/>
Expand Down
2 changes: 1 addition & 1 deletion tools/cojac/macros.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<macros>
<token name="@TOOL_VERSION@">0.9.2</token>
<token name="@TOOL_VERSION@">0.9.3</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@PROFILE@">21.01</token>
<xml name="biotools">
Expand Down
2 changes: 1 addition & 1 deletion tools/ensembl_vep/ensembl_vep.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tool id="ensembl_vep" name="Predict variant effects" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@">
<description>with VEP</description>
<macros>
<token name="@TOOL_VERSION@">113.2</token>
<token name="@TOOL_VERSION@">113.3</token>
<token name="@VERSION_SUFFIX@">0</token>
<token name="@DB_VERSION@">108</token>
<xml name="vcf_input">
Expand Down
2 changes: 1 addition & 1 deletion tools/mosdepth/mosdepth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</sanitizer>
<validator type="regex">([0-9A-Za-z!#$%&amp;+./:;?@^_|~-][0-9A-Za-z!#$%&amp;*+./:;=?@^_|~-]*)?</validator>
</xml>
<token name="@TOOL_VERSION@">0.3.8</token>
<token name="@TOOL_VERSION@">0.3.10</token>
</macros>
<requirements>
<requirement type="package" version="@TOOL_VERSION@">mosdepth</requirement>
Expand Down
74 changes: 74 additions & 0 deletions tools/phyloseq/phyloseq_plot_bar.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env Rscript

# Load libraries
suppressPackageStartupMessages(library("optparse"))
suppressPackageStartupMessages(library("phyloseq"))
suppressPackageStartupMessages(library("ggplot2"))

# Define options
option_list <- list(
make_option(c("--input"),
action = "store", dest = "input",
help = "Input file containing a phyloseq object"
),
make_option(c("--x"),
action = "store", dest = "x",
help = "Variable for x-axis (e.g., 'Sample', 'Phylum')"
),
make_option(c("--fill"),
action = "store", dest = "fill", default = NULL,
help = "Variable for fill color (e.g., 'Genus', 'Order') (optional)"
),
make_option(c("--facet"),
action = "store", dest = "facet", default = NULL,
help = "Facet by variable (optional)"
),
make_option(c("--output"),
action = "store", dest = "output",
help = "Output file (PDF)"
)
)

# Parse arguments
parser <- OptionParser(usage = "%prog [options] file", option_list = option_list)
args <- parse_args(parser, positional_arguments = TRUE)
opt <- args$options

# Validate required options
if (is.null(opt$input) || opt$input == "") {
stop("Error: Input file is required.")
}
if (is.null(opt$x) || opt$x == "") {
stop("Error: X-axis variable is required.")
}
if (is.null(opt$output) || opt$output == "") {
stop("Error: Output file is required.")
}

# Load phyloseq object
print(paste("Trying to read:", opt$input))
physeq <- readRDS(opt$input)

# Check if the 'x' and 'fill' variables are valid
sample_vars <- colnames(sample_data(physeq))
if (!opt$x %in% sample_vars) {
stop(paste("Error: X-axis variable", opt$x, "does not exist in the sample data."))
}

# Generate bar plot
p <- plot_bar(physeq, x = opt$x, fill = opt$fill)

# Only facet if the facet variable is provided and exists in the sample data
if (!is.null(opt$facet) && opt$facet != "") {
if (opt$facet %in% sample_vars) {
p <- p + facet_wrap(as.formula(paste("~", opt$facet)))
} else {
warning(paste("Facet variable", opt$facet, "does not exist in the sample data. Faceting will be skipped."))
}
}

# Save to output file using PDF device
print(paste("Saving plot to:", opt$output))
pdf(file = opt$output, width = 10, height = 8)
print(p)
dev.off()
76 changes: 76 additions & 0 deletions tools/phyloseq/phyloseq_plot_bar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<tool id="phyloseq_plot_bar" name="Phyloseq: Bar Chart" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
<description>Generate bar charts from a phyloseq object</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="bio_tools"/>
<expand macro="requirements"/>
<command detect_errors="exit_code"><![CDATA[
Rscript '${__tool_directory__}/phyloseq_plot_bar.R'
--input '$input'
--x '$x'
--fill '$fill'
--facet '${facet}'
--output '$output'
]]></command>
<inputs>
<expand macro="phyloseq_input"/>
<param name="x" type="text" label="X-axis variable" help="Variable for the x-axis (e.g., Sample, Phylum)" />
<param name="fill" type="text" label="Fill variable" help="Variable to color the bars (e.g., Genus, Order)" />
<param name="facet" type="text" optional="true" label="Facet by variable" help="Optional: Variable to facet the chart by (e.g., SampleType)" />
</inputs>
<outputs>
<data name="output" format="pdf" label="Bar Chart (PDF)" />
</outputs>
<tests>
<!-- Test 1: Default parameters -->
<test>
<param name="input" value="output.phyloseq" ftype="phyloseq"/>
<param name="x" value="Property"/>
<param name="fill" value="Number"/>
<param name="facet" value="Property"/>
<output name="output" ftype="pdf">
<assert_contents>
<has_text text="%PDF"/>
<has_text text="%%EOF"/>
</assert_contents>
</output>
</test>
<!-- Test 2: Valid parameters without facet -->
<test>
<param name="input" value="output.phyloseq" ftype="phyloseq"/>
<param name="x" value="Property"/>
<param name="fill" value="Number"/>
<param name="facet" value=""/>
<output name="output" ftype="pdf">
<assert_contents>
<has_text text="%PDF"/>
<has_text text="%%EOF"/>
</assert_contents>
</output>
</test>
</tests>

<help>
**Description**

This tool generates bar charts from a phyloseq object using the `plot_bar` function.

**Inputs**

- **Input**: A phyloseq object in RDS format.
- **X-axis variable**: The variable to use for the x-axis (e.g., Sample, Phylum).
- **Fill variable**: (Optional) The variable to use for the bar fill colors (e.g., Genus, Order).
- **Facet by variable**: (Optional) A variable to facet the bar chart (e.g., SampleType).

**Outputs**

- A PDF file containing the bar chart.

**Usage Notes**

Ensure that the input file is a valid phyloseq object in RDS format.
</help>
<expand macro="citations"/>
</tool>

2 changes: 1 addition & 1 deletion tools/ucsc_tools/fatovcf/fatovcf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Convert a FASTA alignment file to Variant Call Format (VCF) single-nucleotide diffs
</description>
<macros>
<token name="@TOOL_VERSION@">448</token>
<token name="@TOOL_VERSION@">473</token>
</macros>
<xrefs>
<xref type="bio.tools">UCSC_Genome_Browser_Utilities</xref>
Expand Down

0 comments on commit e84dae7

Please sign in to comment.