root/galaxy-central/tools/maf/maf_filter.xml @ 3

リビジョン 2, 10.6 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1<tool id="MAF_filter" name="Filter MAF" version="1.0.1">
2  <description>by specified attributes</description>
3  <command interpreter="python">maf_filter.py $maf_filter_file $input1 $out_file1 $out_file1.files_path $species $min_size $max_size $min_species_per_block $exclude_incomplete_blocks ${input1.metadata.species}</command>
4  <inputs>
5    <page>
6      <param name="input1" type="data" format="maf" label="MAF File"/>
7      <param name="min_size" label="Minimum Size" value="0" type="integer"/>
8      <param name="max_size" label="Maximum Size" value="0" type="integer" help="A maximum size less than 1 indicates no limit"/>
9      <param name="species" type="select" display="checkboxes" multiple="true" label="Choose species" help="Select species to be included in the final alignment">
10        <options>
11          <filter type="data_meta" ref="input1" key="species" />
12        </options>
13      </param>
14      <param name="min_species_per_block" type="select" label="Exclude blocks which have only one species" >
15        <option value="2">Yes</option>
16        <option value="1" selected="True">No</option>
17      </param>
18      <param name="exclude_incomplete_blocks" type="select" label="Exclude blocks which have missing species" >
19        <option value="1">Yes</option>
20        <option value="0" selected="True">No</option>
21      </param>
22      <repeat name="maf_filters" title="Filter">
23        <param name="species1" type="select" label="When Species" multiple="false">
24          <options>
25            <filter type="data_meta" ref="input1" key="species" />
26          </options>
27        </param>
28        <conditional name="species1_attributes">
29          <param name="species1_attribute_type" type="select" label="Species Attribute">
30            <option value="attribute_strand">Strand</option>
31            <option value="attribute_chr" selected="true">Chromosome</option>
32          </param>
33          <when value="attribute_strand">
34            <param name="species1_is_isnot" type="select" label="Conditional">
35              <option value="==">Is</option>
36              <option value="!=">Is Not</option>
37            </param>
38            <param name="species1_attribute" type="select" label="Strand">
39              <option value="+" selected="true">+</option>
40              <option value="-">-</option>
41            </param>
42            <repeat name="filter_condition" title="Filter Condition">
43              <param name="species2" type="select" label="Species" multiple="false">
44                <options>
45                  <filter type="data_meta" ref="input1" key="species" />
46                </options>
47              </param>
48              <conditional name="species2_attributes">
49                <param name="species2_attribute_type" type="select" label="Species Attribute">
50                  <option value="attribute_strand" selected="true">Strand</option>
51                  <option value="attribute_chr">Chromosome</option>
52                </param>
53                <when value="attribute_strand">
54                  <param name="species2_is_isnot" type="select" label="Conditional">
55                    <option value="==">Is</option>
56                    <option value="!=">Is Not</option>
57                  </param>
58                  <param name="species2_attribute" type="select" label="Strand">
59                    <option value="+" selected="true">+</option>
60                    <option value="-">-</option>
61                  </param>
62                </when>
63                <when value="attribute_chr">
64                  <param name="species2_is_isnot" type="select" label="Conditional">
65                    <option value="in">Is</option>
66                    <option value="not in">Is Not</option>
67                  </param>
68                  <param name="species2_attribute" type="text" label="Chromosome" value="chr1"/>
69                </when>
70              </conditional>
71            </repeat>
72          </when>
73          <when value="attribute_chr">
74            <param name="species1_is_isnot" type="select" label="Conditional">
75              <option value="in">Is</option>
76              <option value="not in">Is Not</option>
77            </param>
78            <param name="species1_attribute" type="text" label="Chromosome" value="chr1"/>
79            <repeat name="filter_condition" title="Filter Condition">
80              <param name="species2" type="select" label="Species" multiple="false">
81                <options>
82                  <filter type="data_meta" ref="input1" key="species" />
83                </options>
84              </param>
85              <conditional name="species2_attributes">
86                <param name="species2_attribute_type" type="select" label="Species Attribute">
87                  <option value="attribute_strand">Strand</option>
88                  <option value="attribute_chr" selected="true">Chromosome</option>
89                </param>
90                <when value="attribute_strand">
91                  <param name="species2_is_isnot" type="select" label="Conditional">
92                    <option value="==">Is</option>
93                    <option value="!=">Is Not</option>
94                  </param>
95                  <param name="species2_attribute" type="select" label="Strand">
96                    <option value="+" selected="true">+</option>
97                    <option value="-">-</option>
98                  </param>
99                </when>
100                <when value="attribute_chr">
101                  <param name="species2_is_isnot" type="select" label="Conditional">
102                    <option value="in">Is</option>
103                    <option value="not in">Is Not</option>
104                  </param>
105                  <param name="species2_attribute" type="text" label="Chromosome" value="chr1"/>
106                </when>
107              </conditional>
108            </repeat>
109          </when>
110        </conditional>
111      </repeat>
112    </page>
113  </inputs>
114  <configfiles>
115    <configfile name="maf_filter_file">
116#set $is_isnot_valid = {"==":"==", "!=":"!=", "in":"in", "not in":"not in"}
117def maf_block_pass_filter( maf_block ):
118#for $maf_filter in $maf_filters:
119#if $len( $maf_filter['species1_attributes']['filter_condition'] ) == 0:
120#continue
121#end if
122    primary_component = maf_block.get_component_by_src_start( """$maf_filter['species1'].value.encode( 'string_escape' )""".decode( 'string_escape' ) )
123    if primary_component is not None:
124#if $maf_filter['species1_attributes']['species1_attribute_type'] == 'attribute_chr':
125        if primary_component.src.split( "." )[-1] $is_isnot_valid.get( $maf_filter['species1_attributes']['species1_is_isnot'].value.strip(), 'is in' ) """$maf_filter['species1_attributes']['species1_attribute'].value.encode( 'string_escape' )""".decode( 'string_escape' ).split( "," ):
126#else
127        if primary_component.strand $is_isnot_valid.get( $maf_filter['species1_attributes']['species1_is_isnot'].value.strip(), '==' ) """$maf_filter['species1_attributes']['species1_attribute'].value.encode( 'string_escape' )""".decode( 'string_escape' ):
128#end if
129#for $filter_condition in $maf_filter['species1_attributes']['filter_condition']:
130            secondary_component = maf_block.get_component_by_src_start( """$filter_condition['species2'].value.encode( 'string_escape' )""".decode( 'string_escape' ) )
131#if $filter_condition['species2_attributes']['species2_attribute_type'] == 'attribute_chr':
132            if secondary_component is not None:
133                if not ( secondary_component.src.split( "." )[-1] $is_isnot_valid.get( $filter_condition['species2_attributes']['species2_is_isnot'].value.strip(), 'is in' ) """$filter_condition['species2_attributes']['species2_attribute'].value.encode( 'string_escape' )""".decode( 'string_escape' ).split( "," ) ):
134                    return False
135#else:
136            if secondary_component is not None:
137                if not ( secondary_component.strand $is_isnot_valid.get( $filter_condition['species2_attributes']['species2_is_isnot'].value.strip(), '==' ) """$filter_condition['species2_attributes']['species2_attribute'].value.encode( 'string_escape' )""".decode( 'string_escape' ) ):
138                    return False
139#end if
140#end for
141#end for
142    return True
143ret_val = maf_block_pass_filter( maf_block )
144</configfile>
145  </configfiles>
146  <outputs>
147    <data format="maf" name="out_file1" />
148  </outputs>
149<!--
150  <tests>
151    <test>
152      <param name="input1" value="4.maf"/>
153      <param name="species" value="bosTau2,canFam2,hg17,panTro1,rheMac2,rn3"/>
154      <param name="exclude_incomplete_blocks" value="0"/>
155      <param name="min_species_per_block" value="1"/>
156      <param name="min_size" value="0"/>
157      <param name="max_size" value="0"/>
158      <param name="species1" value="hg17"/>
159      <param name="species2" value="hg17"/>
160      <param name="species1_attribute_type" value="attribute_chr"/>
161      <param name="species1_is_isnot" value="in"/>
162      <param name="species1_attribute" value="chr1"/>
163      <param name="filter_condition"/> Test will ERROR when this is set or when it is not set.
164     
165      <output name="out_file1" file="cf_maf_limit_to_species.dat"/>
166    </test>
167  </tests>
168-->
169<help>
170This tool allows you to build complex filters to be applied to each alignment block of a MAF file. You can define restraints on species based upon chromosome and strand. You can specify comma separated lists of chromosomes where appropriate.
171
172.. class:: infomark
173
174For example, this tool is useful to restrict a set of alignments to only those blocks which contain alignments between chromosomes that are considered homologous.
175
176-----
177
178.. class:: warningmark
179
180If a species is not found in a particular block, all filters on that species are ignored.
181
182-----
183
184This tool allows the user to remove any undesired species from a MAF file. If no species are specified then all species will be kept. If species are specified, columns which contain only gaps are removed. The options for this are:
185
186 * **Exclude blocks which have missing species** - suppose you want to restrict an 8-way alignment to human, mouse, and rat.  The tool will first remove all other species. Next, if this option is set to **YES** the tool WILL NOT return MAF blocks, which do not include human, mouse, or rat. This means that all alignment blocks returned by the tool will have exactly three sequences in this example.
187
188 * **Exclude blocks which have only one species** - if this option is set to **YES** all single sequence alignment blocks WILL NOT be returned.
189
190-----
191
192You can also provide a size range and limit your output to the MAF blocks which fall within the specified range.
193
194</help>
195</tool>
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。