Mercurial > repos > goeckslab > rename_tiff_channels
annotate rename_tiff_channels.xml @ 0:18f6be63414c draft
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
author | goeckslab |
---|---|
date | Thu, 29 Sep 2022 16:53:36 +0000 |
parents | |
children | d2c59a1ac0c4 |
rev | line source |
---|---|
0
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
1 <tool id="rename_tiff_channels" name="Rename OME-TIFF Channels" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@"> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
2 <description>Change the channel names in the XML metadata of OME-TIFF images</description> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
3 <macros> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
4 <import>macros.xml</import> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
5 </macros> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
6 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
7 <expand macro="requirements"/> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
8 <expand macro="version_cmd"/> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
9 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
10 <stdio> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
11 <regex match=".*XMLSyntaxError.*" |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
12 source="stderr" |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
13 level="fatal" |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
14 description="XML metadata does not adhere to OME format. Considering converting image to OME-TIFF" /> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
15 </stdio> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
16 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
17 <command detect_errors="aggressive"><![CDATA[ |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
18 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
19 cp '$image' ./renamed_image.ome.tiff && |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
20 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
21 ln -s '$channel_csv' ./channels.csv && |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
22 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
23 python '$script' |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
24 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
25 ]]></command> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
26 <configfiles> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
27 <configfile name = "script"> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
28 import os |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
29 import sys |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
30 import argparse |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
31 import pandas as pd |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
32 import ome_types |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
33 from ome_types.model import channel |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
34 from tifffile import tiffcomment |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
35 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
36 cwd = os.getcwd() |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
37 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
38 channels_df = pd.read_csv(os.path.join(cwd, 'channels.csv')) |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
39 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
40 original_ome_xml = tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff')) |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
41 working_ome = ome_types.from_xml(original_ome_xml, parser = 'lxml') |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
42 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
43 for l_idx, level in enumerate(working_ome.images): |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
44 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
45 for c_idx, channel in enumerate(level.pixels.channels): |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
46 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
47 new_name = channels_df.loc[c_idx, 'marker_name'] |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
48 channel.name = new_name |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
49 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
50 if l_idx == 0: |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
51 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
52 print(f"Channel {c_idx} renamed to {new_name}") |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
53 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
54 updated_ome_xml = working_ome.to_xml() |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
55 tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff'), updated_ome_xml) |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
56 |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
57 print("Updated OME-TIFF metadata:") |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
58 print(tiffcomment(os.path.join(cwd, 'renamed_image.ome.tiff'))) |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
59 </configfile> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
60 </configfiles> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
61 <inputs> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
62 <param name="image" type="data" format="ome.tiff" label="Input image in OME-tiff format"/> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
63 <param name="channel_csv" type="data" format="csv" label="Channel Metadata CSV"/> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
64 </inputs> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
65 <outputs> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
66 <data name="renamed_image" format="ome.tiff" from_work_dir="renamed_image.ome.tiff" label="${tool.name} on ${on_string}"/> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
67 </outputs> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
68 <tests> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
69 <test> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
70 <param name="image" value="rename_test.tiff" /> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
71 <param name="channel_csv" value="rename_channels.csv" /> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
72 <output name="renamed_image" ftype="ome.tiff"> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
73 <assert_contents> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
74 <has_size value="44000" delta="1000" /> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
75 </assert_contents> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
76 </output> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
77 <assert_stdout> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
78 <has_text text="Channel 0 renamed to DNA_6" /> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
79 <has_text text="Updated OME-TIFF metadata" /> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
80 </assert_stdout> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
81 </test> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
82 </tests> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
83 <help><![CDATA[ |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
84 ]]></help> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
85 <expand macro="citations" /> |
18f6be63414c
planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/mti-utils commit 339f5497446066ca76c27460da2eef4f6e0fa36e
goeckslab
parents:
diff
changeset
|
86 </tool> |