changeset 9:22fe0154fa54

added support for heterochromatic regions
author Richard Burhans <burhans@bx.psu.edu>
date Tue, 10 Jul 2012 11:41:22 -0400
parents 30771a097f14
children 9b92372de9f6
files LocationFile.py dpmix.py dpmix_plot.py
diffstat 3 files changed, 23 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/LocationFile.py	Wed Jun 20 14:02:30 2012 -0400
+++ b/LocationFile.py	Tue Jul 10 11:41:22 2012 -0400
@@ -57,3 +57,13 @@
                 return rval
         else:
             die( 'key "{0}" not found in location file {1}'.format( key, self.filename ) )
+
+    def get_values_if_exists( self, key ):
+        if key in self._map:
+            rval = self._map[key]
+            if len( rval ) == 1:
+                return rval[0]
+            else:
+                return rval
+        else:
+            return None
--- a/dpmix.py	Wed Jun 20 14:02:30 2012 -0400
+++ b/dpmix.py	Tue Jul 10 11:41:22 2012 -0400
@@ -7,6 +7,7 @@
 from Population import Population
 import gd_composite
 from dpmix_plot import make_dpmix_plot
+from LocationFile import LocationFile
 
 ################################################################################
 
@@ -40,17 +41,22 @@
 
 ################################################################################
 
-if len(sys.argv) < 14:
+if len(sys.argv) < 15:
     print "usage"
     sys.exit(1)
 
-input, data_source, switch_penalty, ap1_input, ap2_input, p_input, output, output2, output2_dir, dbkey, ref_column, galaxy_data_index_dir = sys.argv[1:13]
-individual_metadata = sys.argv[13:]
+input, data_source, switch_penalty, ap1_input, ap2_input, p_input, output, output2, output2_dir, dbkey, ref_column, galaxy_data_index_dir, heterochromatin_loc_file = sys.argv[1:14]
+individual_metadata = sys.argv[14:]
 
 chrom = 'all'
-analyze_additional = '0'
 add_logs = '0'
 
+loc_path = os.path.join(galaxy_data_index_dir, heterochromatin_loc_file)
+location_file = LocationFile(loc_path)
+heterochrom_path = location_file.get_values_if_exists(dbkey)
+if heterochrom_path is None:
+    heterochrom_path = '/dev/null'
+
 population_list = []
 
 p_total = Population()
@@ -93,7 +99,7 @@
 args.append(data_source)
 args.append(add_logs)
 args.append(switch_penalty)
-args.append(analyze_additional)
+args.append(heterochrom_path)
 args.append(misc_file)
 
 columns = ap1.column_list()
@@ -138,18 +144,11 @@
 elif data_source == '1':
     data_source_value = 'estimated genotype'
 
-if analyze_additional == '0':
-    analyze_additional_value = 'no'
-elif analyze_additional == '1':
-    analyze_additional_value = 'yes'
-
 in_data_source = gd_composite.Parameter(description='Data source', value=data_source_value, display_type=display_value)
 in_switch_penalty = gd_composite.Parameter(description='Switch penalty', value=switch_penalty, display_type=display_value)
-in_analyze_additional = gd_composite.Parameter(description='Also analyze random chromosome', value=analyze_additional_value, display_type=display_value)
 
 info_page.add_input_parameter(in_data_source)
 info_page.add_input_parameter(in_switch_penalty)
-info_page.add_input_parameter(in_analyze_additional)
 
 misc_populations =  gd_composite.Parameter(name='Populations', value=population_list, display_type=gd_composite.DisplayPopulationList())
 
--- a/dpmix_plot.py	Wed Jun 20 14:02:30 2012 -0400
+++ b/dpmix_plot.py	Tue Jul 10 11:41:22 2012 -0400
@@ -119,6 +119,8 @@
         return make_split_rectangle(p1, p2, 'r', 'g')
     elif state == 2:
         return [ make_rectangle(p1, p2, 'g') ]
+    elif state == 3:
+        return [ make_rectangle(p1, p2, '#c7c7c7') ]
     else:
         print >> sys.stderr, "Unknown state: {0}: {1} {2} {3} {4}".format(state, chrom, p1, p2, state, individual)
         sys.exit(1)