changeset 2:efa2b391e887 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/weightedaverage commit f770c3c58f1e7e1fa5ed22d7f7aca856d36729e8
author devteam
date Wed, 05 Oct 2016 13:39:38 -0400
parents 90611e86a998
children
files WeightedAverage.py WeightedAverage.xml test-data/interpolate_result_zeros.bed tool_dependencies.xml
diffstat 4 files changed, 254 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/WeightedAverage.py	Thu Apr 03 09:34:41 2014 -0400
+++ b/WeightedAverage.py	Wed Oct 05 13:39:38 2016 -0400
@@ -3,6 +3,7 @@
 usage: %prog bed_file_1 bed_file_2 out_file
     -1, --cols1=N,N,N,N: Columns for chr, start, end, strand in first file
     -2, --cols2=N,N,N,N,N: Columns for chr, start, end, strand, name/value in second file
+    -z, --allow_zeros: Include zeros in calculations
 """
 
 import collections
@@ -42,6 +43,11 @@
 def GetOverlap(a, b):
     return min(a[1], b[1])-max(a[0], b[0])
 
+def get_float_no_zero( field ):
+    rval = float( field )
+    assert rval
+    return rval
+
 
 options, args = doc_optparse.parse( __doc__ )
 
@@ -53,38 +59,37 @@
     print eee
     stop_err( "Data issue: click the pencil icon in the history item to correct the metadata attributes." )
 
-fd2 = open(input2)
-lines2 = fd2.readlines()
+if options.allow_zeros:
+    get_value = float
+else:
+    get_value = get_float_no_zero
 RecombChrDict = collections.defaultdict(list)
 
 skipped = 0
-for line in lines2:
+for line in open( input2 ):
     temp = line.strip().split()
     try:
-        assert float(temp[int(name_col_2)])
-    except:
+        value = get_value( temp[ name_col_2 ] )
+    except Exception:
         skipped += 1
         continue
-    tempIndex = [int(temp[int(start_col_2)]), int(temp[int(end_col_2)]), float(temp[int(name_col_2)])]
-    RecombChrDict[temp[int(chr_col_2)]].append(tempIndex)
+    tempIndex = [ int( temp[ start_col_2 ] ), int( temp[ end_col_2 ] ), value ]
+    RecombChrDict[ temp[ chr_col_2 ] ].append( tempIndex )
 
 print "Skipped %d features with invalid values" % (skipped)
 
-fd1 = open(input1)
-lines = fd1.readlines()
-finalProduct = ''
-for line in lines:
-    temp = line.strip().split('\t')
-    chromosome = temp[int(chr_col_1)]
-    start = int(temp[int(start_col_1)])
-    stop = int(temp[int(end_col_1)])
+fdd = open( input3, 'w' )
+for line in open( input1 ):
+    line = line.strip()
+    temp = line.split('\t')
+    chromosome = temp[ chr_col_1 ]
+    start = int( temp[ start_col_1 ] )
+    stop = int( temp[ end_col_1 ] )
     start_stop = [start, stop]
     RecombRate = FindRate( chromosome, start_stop, RecombChrDict )
     try:
         RecombRate = "%.4f" % (float(RecombRate))
     except:
         RecombRate = RecombRate
-    finalProduct += line.strip()+'\t'+str(RecombRate)+'\n'
-fdd = open(input3, 'w')
-fdd.writelines(finalProduct)
+    fdd.write( "%s\t%s\n" % ( line, RecombRate ) )
 fdd.close()
--- a/WeightedAverage.xml	Thu Apr 03 09:34:41 2014 -0400
+++ b/WeightedAverage.xml	Wed Oct 05 13:39:38 2016 -0400
@@ -1,14 +1,15 @@
-<tool id="wtavg" name="Assign weighted-average" version="1.0.0">
+<tool id="wtavg" name="Assign weighted-average" version="1.0.1">
   <description> of the values of features overlapping an interval </description>
   <requirements>
     <requirement type="package" version="1.0.0">galaxy-ops</requirement>
     <requirement type="package" version="0.7.1">bx-python</requirement>
   </requirements>
-  <command interpreter="python">WeightedAverage.py  $genomic_interval $genomic_feature $out_file1 -1 ${genomic_interval.metadata.chromCol},${genomic_interval.metadata.startCol},${genomic_interval.metadata.endCol},${genomic_interval.metadata.strandCol} -2 ${genomic_feature.metadata.chromCol},${genomic_feature.metadata.startCol},${genomic_feature.metadata.endCol},${genomic_feature.metadata.strandCol},${genomic_feature.metadata.nameCol}</command>
+  <command interpreter="python">WeightedAverage.py  $genomic_interval $genomic_feature $out_file1 -1 ${genomic_interval.metadata.chromCol},${genomic_interval.metadata.startCol},${genomic_interval.metadata.endCol},${genomic_interval.metadata.strandCol} -2 ${genomic_feature.metadata.chromCol},${genomic_feature.metadata.startCol},${genomic_feature.metadata.endCol},${genomic_feature.metadata.strandCol},${genomic_feature.metadata.nameCol} ${allow_zeros}</command>
 
   <inputs>
     <param format="interval" name="genomic_interval" type="data" label="Genomic intervals (first dataset)" help="Dataset missing? See Note below."/>
     <param format="interval" name="genomic_feature" label="Genomic features (second dataset)" type="data" help="Make sure the value column is specified. See Note below." />
+    <param name="allow_zeros" label="Include zeros in calculations" type="boolean" help="Otherwise, skip them as bad values" truevalue="--allow_zeros" falsevalue="" checked="True" />
   </inputs>
   <outputs>
     <data format="input" name="out_file1" metadata_source="genomic_interval" />
@@ -18,9 +19,15 @@
     <test>
       <param name="genomic_interval" value="interval_interpolate.bed"/>
       <param name="genomic_feature" value="value_interpolate.bed"/>
+      <param name="allow_zeros" value="False" />
       <output name="out_file1" file="interpolate_result.bed"/>
     </test>
-    
+    <test>
+      <param name="genomic_interval" value="interval_interpolate.bed"/>
+      <param name="genomic_feature" value="value_interpolate.bed"/>
+      <param name="allow_zeros" value="True" />
+      <output name="out_file1" file="interpolate_result_zeros.bed"/>
+    </test>
   </tests>
   <help>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/interpolate_result_zeros.bed	Wed Oct 05 13:39:38 2016 -0400
@@ -0,0 +1,219 @@
+chr1	27800000	29750669	6600000	0	1.7386
+chr1	29800669	34400000	6600000	0	1.7920
+chr1	46500000	51300000	4800000	0	1.4004
+chr1	102000000	103636494	5000000	0	1.2007
+chr1	103686494	103843838	5000000	0	NA
+chr1	103893838	107000000	5000000	0	1.1883
+chr1	117600000	120498679	3100000	0	1.4007
+chr1	120548679	120700000	3100000	0	NA
+chr1	153300000	154800000	1500000	0	1.9511
+chr1	163800000	171200000	7400000	0	1.4719
+chr1	174300000	184000000	9700000	0	1.5022
+chr10	6700000	12300000	5600000	0	1.5533
+chr10	42100000	45746970	11200000	0	1.4905
+chr10	45896970	46849175	11200000	0	NA
+chr10	46999175	47262482	11200000	0	1.4600
+chr10	47412482	47575713	11200000	0	NA
+chr10	47725713	48715542	11200000	0	1.3900
+chr10	48865542	50807416	11200000	0	1.7448
+chr10	50857416	51068851	11200000	0	NA
+chr10	51118851	53300000	11200000	0	1.3877
+chr10	74600000	81231464	15000000	0	1.1798
+chr10	81241464	89600000	15000000	0	1.4475
+chr10	98000000	99400000	1400000	0	1.7700
+chr10	102000000	111800000	9800000	0	1.4549
+chr10	114900000	119100000	4200000	0	1.3184
+chr10	127400000	128606059	7974737	0	1.2600
+chr10	128656059	133271394	7974737	0	1.3583
+chr10	133281394	133527517	7974737	0	NA
+chr10	133577517	135374737	7974737	0	1.4720
+chr11	50000	1152759	2800000	0	1.5200
+chr11	1169335	2800000	2800000	0	1.6101
+chr11	12600000	16100000	3500000	0	1.2212
+chr11	21600000	26000000	4400000	0	1.3320
+chr11	27200000	31000000	3800000	0	1.2483
+chr11	48800000	50740429	2600000	0	1.3100
+chr11	50947429	51400000	2600000	0	NA
+chr11	56400000	68846377	12800000	0	1.7959
+chr11	68848982	69200000	12800000	0	1.6400
+chr11	70700000	85300000	14600000	0	1.5591
+chr11	87900000	92300000	4400000	0	1.2134
+chr11	110000000	115400000	5400000	0	1.4715
+chr11	120700000	134452384	13752384	0	1.4668
+chr12	36500000	44600000	8100000	0	1.3403
+chr12	53100000	56300000	3200000	0	1.6808
+chr12	69800000	74791940	8900000	0	1.2548
+chr12	75041940	78700000	8900000	0	1.2656
+chr12	91200000	94800000	3600000	0	1.6655
+chr12	100000000	107500000	7500000	0	1.6243
+chr13	18400000	32900000	14500000	0	1.5346
+chr13	34700000	39500000	4800000	0	1.1758
+chr13	52200000	57600000	5400000	0	1.2506
+chr13	60500000	72100000	11600000	0	1.2112
+chr13	100500000	109100000	8600000	0	1.3144
+chr14	23600000	31800000	8200000	0	1.3057
+chr14	36900000	41000000	4100000	0	1.2309
+chr14	43200000	48300000	5100000	0	1.2680
+chr14	69300000	72900000	3600000	0	1.6758
+chr14	78400000	88900000	10500000	0	1.2495
+chr15	23300000	24687593	2400000	0	1.2379
+chr15	24731593	25169606	2400000	0	1.2200
+chr15	25270606	25700000	2400000	0	NA
+chr15	31400000	37900000	6500000	0	1.4543
+chr15	65300000	70400000	5100000	0	1.6950
+chr16	0	8576922	14700000	0	1.5411
+chr16	8594422	14700000	14700000	0	1.5935
+chr16	16700000	21700000	5000000	0	1.6366
+chr16	69400000	78200000	8800000	0	1.4012
+chr16	80500000	82700000	2200000	0	1.5200
+chr17	0	296854	11200000	0	NA
+chr17	343376	11200000	11200000	0	1.7399
+chr17	28800000	31699961	6600000	0	1.4123
+chr17	31799961	33429230	6600000	0	1.7100
+chr17	33529230	35400000	6600000	0	1.8415
+chr17	47600000	54900000	7300000	0	1.4561
+chr17	55600000	59900000	4300000	0	1.5958
+chr18	17300000	31000000	13700000	0	1.3855
+chr18	35500000	50313134	16500000	0	1.2743
+chr18	50360134	52000000	16500000	0	1.3600
+chr19	11000	7297004	12600000	0	1.8232
+chr19	7302004	8593198	12600000	0	2.1300
+chr19	8598198	12600000	12600000	0	1.7010
+chr2	12800000	16171403	4200000	0	1.2641
+chr2	16221403	17000000	4200000	0	1.2505
+chr2	19100000	21012571	4800000	0	1.2500
+chr2	21037571	23900000	4800000	0	1.4405
+chr2	47600000	52700000	5100000	0	1.2384
+chr2	54800000	61100000	6300000	0	1.4715
+chr2	75400000	83700000	8300000	0	1.1639
+chr2	102100000	108600000	6500000	0	1.3381
+chr2	113800000	118600000	4800000	0	1.1949
+chr2	129600000	134800000	5200000	0	1.3332
+chr2	136600000	144700000	8100000	0	1.3447
+chr2	189100000	197100000	8000000	0	1.4590
+chr2	209100000	215100000	6000000	0	1.3963
+chr2	221300000	233711985	15700000	0	1.3701
+chr2	233731985	237000000	15700000	0	1.4560
+chr20	5000000	9000000	4000000	0	1.3515
+chr20	11900000	17800000	5900000	0	1.3648
+chr20	21200000	25700000	4500000	0	1.4588
+chr20	37100000	41100000	4000000	0	1.3980
+chr20	49200000	54400000	5200000	0	1.5272
+chr21	38600000	41877429	8344323	0	1.6542
+chr21	41878628	43505733	8344323	0	1.9800
+chr21	43507092	46944323	8344323	0	1.6567
+chr22	16300000	18889431	11600000	0	NA
+chr22	18939431	27900000	11600000	0	1.6362
+chr22	30500000	39300000	8800000	0	1.7639
+chr22	42600000	43057958	7091432	0	1.5600
+chr22	43107958	47356150	7091432	0	1.5400
+chr22	47366250	48750436	7091432	0	1.4700
+chr22	48767136	49087576	7091432	0	NA
+chr22	49089176	49107103	7091432	0	NA
+chr22	49126803	49591432	7091432	0	NA
+chr3	14700000	23800000	9100000	0	1.3438
+chr3	26400000	32100000	5700000	0	1.2751
+chr3	54400000	58500000	4100000	0	1.4670
+chr3	63700000	66115833	8100000	0	1.1571
+chr3	66375833	71800000	8100000	0	1.4022
+chr3	74200000	87200000	13000000	0	1.2224
+chr3	104400000	123400000	19000000	0	1.4382
+chr3	144400000	150400000	6000000	0	1.2844
+chr4	0	1413146	5200000	0	NA
+chr4	1464146	3883456	5200000	0	1.8696
+chr4	3963456	5200000	5200000	0	1.4193
+chr4	40900000	45600000	4700000	0	1.3101
+chr4	59200000	59429326	17300000	0	NA
+chr4	59479326	69275441	17300000	0	1.1989
+chr4	69375441	71536854	17300000	0	1.4800
+chr4	71711854	75641303	17300000	0	1.3813
+chr4	75671303	76500000	17300000	0	NA
+chr4	102500000	120600000	18100000	0	1.2796
+chr4	124000000	151000000	27000000	0	1.3180
+chr5	42400000	45800000	3400000	0	1.6600
+chr5	135400000	138812257	11800000	0	1.6903
+chr5	138817257	147200000	11800000	0	1.4559
+chr6	5000	4100000	4100000	0	1.4960
+chr6	7000000	9199728	6500000	0	1.3742
+chr6	9249728	13500000	6500000	0	1.5531
+chr6	15500000	23500000	8000000	0	1.3678
+chr6	26100000	40600000	14500000	0	1.5998
+chr6	45200000	57200000	12000000	0	1.3561
+chr6	63500000	70000000	6500000	0	1.2305
+chr6	75900000	87500000	11600000	0	1.3037
+chr6	92100000	95737264	7800000	0	1.1620
+chr6	95937264	99900000	7800000	0	1.2897
+chr6	139100000	149100000	10000000	0	1.4172
+chr6	164400000	167766922	6499992	0	1.2400
+chr6	167784922	170021897	6499992	0	1.5383
+chr6	170171897	170896992	6499992	0	1.4900
+chr7	19500000	35600000	16100000	0	1.5139
+chr7	37500000	43300000	5800000	0	1.4283
+chr7	46600000	48167949	7300000	0	1.3900
+chr7	48207949	50338125	7300000	0	1.4468
+chr7	50378125	53900000	7300000	0	1.3027
+chr7	61100000	61314455	36800000	0	NA
+chr7	61364455	61554592	36800000	0	NA
+chr7	61604592	74353660	36800000	0	1.4805
+chr7	74603660	97900000	36800000	0	1.3240
+chr7	117200000	130100000	12900000	0	1.3323
+chr7	132400000	137300000	4900000	0	1.4019
+chr7	142800000	147500000	4700000	0	1.1759
+chr8	12700000	19100000	6400000	0	1.1690
+chr8	29700000	29732668	8800000	0	NA
+chr8	29798768	38500000	8800000	0	1.4250
+chr8	55600000	66100000	10500000	0	1.5225
+chr8	74000000	86069241	13200000	0	1.3023
+chr8	86193341	86763703	13200000	0	NA
+chr8	86851003	87200000	13200000	0	NA
+chr8	99100000	101600000	2500000	0	1.6452
+chr8	106100000	117700000	11600000	0	1.2240
+chr8	127300000	140000000	12700000	0	1.4038
+chr9	9000000	14100000	5100000	0	1.2167
+chr9	40200000	40223029	6500000	0	NA
+chr9	40273029	40415834	6500000	0	NA
+chr9	40465834	40930341	6500000	0	NA
+chr9	40980341	41133214	6500000	0	NA
+chr9	41183214	41355793	6500000	0	NA
+chr9	41405793	42603951	6500000	0	NA
+chr9	42653951	43203694	6500000	0	NA
+chr9	43253694	43886565	6500000	0	NA
+chr9	43936565	44616642	6500000	0	NA
+chr9	44666642	44848289	6500000	0	NA
+chr9	44898289	45190199	6500000	0	NA
+chr9	45240199	45705517	6500000	0	NA
+chr9	45755517	46106426	6500000	0	NA
+chr9	46156426	46351035	6500000	0	NA
+chr9	46401035	46700000	6500000	0	NA
+chr9	91000000	91533236	10600000	0	NA
+chr9	91583236	91668616	10600000	0	NA
+chr9	91718616	101600000	10600000	0	1.5580
+chrX	0	34821	6000000	0	NA
+chrX	84821	171384	6000000	0	NA
+chrX	201384	967557	6000000	0	NA
+chrX	1017557	1054113	6000000	0	NA
+chrX	1104113	1184234	6000000	0	NA
+chrX	1274234	2028238	6000000	0	NA
+chrX	2128238	6000000	6000000	0	1.4520
+chrX	9500000	37008177	37800000	0	1.4047
+chrX	37033177	47300000	37800000	0	1.4817
+chrX	65000000	67700000	2700000	0	1.2658
+chrX	76000000	76570348	22200000	0	NA
+chrX	76590348	98200000	22200000	0	1.2642
+chrX	102500000	113403924	18200000	0	1.3809
+chrX	113473924	115596318	18200000	0	1.3900
+chrX	115616318	120700000	18200000	0	1.4886
+chrX	137800000	140100000	2300000	0	1.2054
+chrX	141900000	143335010	5000000	0	1.2700
+chrX	143365010	146900000	5000000	0	1.2517
+chrY	0	34821	11200000	0	NA
+chrY	84821	171384	11200000	0	NA
+chrY	201384	967557	11200000	0	NA
+chrY	1017557	1054113	11200000	0	NA
+chrY	1104113	1184234	11200000	0	NA
+chrY	1274234	2028238	11200000	0	NA
+chrY	2128238	8974955	11200000	0	1.3987
+chrY	9024955	9301322	11200000	0	NA
+chrY	9901322	10714553	11200000	0	1.2200
+chrY	12500000	22310816	14700000	0	1.3632
+chrY	22360816	27200000	14700000	0	1.2357
--- a/tool_dependencies.xml	Thu Apr 03 09:34:41 2014 -0400
+++ b/tool_dependencies.xml	Wed Oct 05 13:39:38 2016 -0400
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
 <tool_dependency>
   <package name="bx-python" version="0.7.1">
-      <repository changeset_revision="2d0c08728bca" name="package_bx_python_0_7" owner="devteam" prior_installation_required="False" toolshed="http://toolshed.g2.bx.psu.edu" />
+      <repository changeset_revision="2d0c08728bca" name="package_bx_python_0_7" owner="devteam" toolshed="https://toolshed.g2.bx.psu.edu" />
     </package>
   <package name="galaxy-ops" version="1.0.0">
-      <repository changeset_revision="4e39032e4ec6" name="package_galaxy_ops_1_0_0" owner="devteam" prior_installation_required="False" toolshed="http://toolshed.g2.bx.psu.edu" />
+      <repository changeset_revision="eef263ff9b95" name="package_galaxy_ops_1_0_0" owner="devteam" toolshed="https://toolshed.g2.bx.psu.edu" />
     </package>
 </tool_dependency>