comparison sample_names.xml @ 0:54380a6171b8 draft default tip

"planemo upload for repository https://github.com/gregvonkuster/galaxy_tools/tree/master/tools/misc/sample_names commit b935f36cfe430263564503ebb71f78dc79315acb"
author greg
date Mon, 22 Nov 2021 00:30:39 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:54380a6171b8
1 <tool id="sample_names" name="Extract sample names" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
2 <description>from input file names</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <command detect_errors="exit_code"><![CDATA[
7 #import difflib
8 #import re
9
10 #if $input_type_cond.input_type == 'single':
11 #set read1 = $input_type_cond.read1
12 #set sample_name = re.sub('[^\s\w\-]', '_', str($read1.element_identifier))
13 #else if $input_type_cond.input_type == 'pair':
14 #set read1 = $input_type_cond.read1
15 #set read1_identifier = re.sub('[^\s\w\-]', '_', str($read1.element_identifier))
16 #set read2 = $input_type_cond.read2
17 #set read2_identifier = re.sub('[^\s\w\-]', '_', str($read2.element_identifier))
18 #set matches = difflib.SequenceMatcher(None, read1_identifier, read2_identifier).get_matching_blocks()
19 #set match = $matches[0]
20 #set sample_name = re.sub('[^\s\w\-]', '_', str($read1_identifier[match.a:match.a + match.size]))
21 #else:
22 #set read1_name = $input_type_cond.reads_collection['forward'].name
23 #set read1_identifier = re.sub('[^\s\w\-]', '_', str($read1_name))
24 #set read2_name = $input_type_cond.reads_collection['reverse'].name
25 #set read2_identifier = re.sub('[^\s\w\-]', '_', str($read2_name))
26 #set matches = difflib.SequenceMatcher(None, read1_identifier, read2_identifier).get_matching_blocks()
27 #set match = $matches[0]
28 #set sample_name = re.sub('[^\s\w\-]', '_', str($read1_identifier[match.a:match.a + match.size]))
29 #end if
30
31 echo '$sample_name' > '$output'
32 ]]></command>
33 <inputs>
34 <conditional name="input_type_cond">
35 <param name="input_type" type="select" label="Choose the category of the files to be analyzed">
36 <option value="single" selected="true">Single dataset</option>
37 <option value="pair">Dataset pair</option>
38 <option value="paired">List of dataset pairs</option>
39 </param>
40 <when value="single">
41 <param name="read1" type="data" format="fastqsanger.gz,fastqsanger" label="Read1 fastq file"/>
42 </when>
43 <when value="pair">
44 <param name="read1" type="data" format="fastqsanger.gz,fastqsanger" label="Read1 fastq file"/>
45 <param name="read2" type="data" format="fastqsanger.gz,fastqsanger" label="Read2 fastq file"/>
46 </when>
47 <when value="paired">
48 <param name="reads_collection" type="data_collection" format="fastqsanger,fastqsanger.gz" collection_type="paired" label="Collection of fastqsanger paired read files"/>
49 </when>
50 </conditional>
51 </inputs>
52 <outputs>
53 <data name="output" format="txt"/>
54 </outputs>
55 <tests>
56 <!-- Single files -->
57 <test>
58 <param name="input_type" value="single"/>
59 <param name="read1" value="CMC_20E1_R1.fastq.gz" dbkey="89"/>
60 <output name="output" file="sample_names.txt" ftype="txt"/>
61 </test>
62 <!-- Paired reads in separate datasets -->
63 <test>
64 <param name="input_type" value="pair"/>
65 <param name="read1" value="CMC_20E1_R1.fastq.gz" dbkey="89"/>
66 <param name="read2" value="CMC_20E1_R2.fastq.gz" dbkey="89"/>
67 <output name="output" file="sample_names2.txt" ftype="txt"/>
68 </test>
69 <!-- Collection of Paired reads -->
70 <test>
71 <param name="input_type" value="paired"/>
72 <param name="reads_collection">
73 <collection type="paired">
74 <element name="forward" value="CMC_20E1_R1.fastq.gz"/>
75 <element name="reverse" value="CMC_20E1_R2.fastq.gz"/>
76 </collection>
77 </param>
78 <output name="output" file="sample_names3.txt" ftype="txt"/>
79 </test>
80 <!-- Collection of Paired reads -->
81 <test>
82 <param name="input_type" value="paired"/>
83 <param name="reads_collection">
84 <collection type="paired">
85 <element name="forward" value="SRR14085881_forward"/>
86 <element name="reverse" value="SRR14085881_reverse"/>
87 </collection>
88 </param>
89 <output name="output" file="sample_names4.txt" ftype="txt"/>
90 </test>
91 </tests>
92 <help>
93 **What it does**
94
95 Accepts fastqsanger sample files, extracts a unique portion of the file name as the sample name, and writes it to
96 the output. The output text file can be consumed by the **Parse parameter value** expression tool to provide workflow
97 parameter values to the **Read group identifier (ID)** and the **Sample name identifier (SM)** parameters in the
98 **Map with BWA-MEM** tool.
99 </help>
100 <expand macro="citations"/>
101 </tool>
102