From ee9db74af90d9d0879f68dff527483e205a8b237 Mon Sep 17 00:00:00 2001 From: preecej Date: Fri, 21 Mar 2014 17:05:01 +0000 Subject: [PATCH] rename program to make it more generic svn path=/; revision=556 --- .../{map_os_2_at.py => incomparanoid.py} | 61 ++++++++----------- 1 file changed, 26 insertions(+), 35 deletions(-) rename Personnel/preecej/python_singletons/{map_os_2_at.py => incomparanoid.py} (86%) diff --git a/Personnel/preecej/python_singletons/map_os_2_at.py b/Personnel/preecej/python_singletons/incomparanoid.py similarity index 86% rename from Personnel/preecej/python_singletons/map_os_2_at.py rename to Personnel/preecej/python_singletons/incomparanoid.py index be86c39..9a8a243 100755 --- a/Personnel/preecej/python_singletons/map_os_2_at.py +++ b/Personnel/preecej/python_singletons/incomparanoid.py @@ -1,6 +1,6 @@ #!/bin/python """ -Script with different analysis methods used to compare Ensembl and Inparanoid species projections. +InComparaNoid: Script with different analysis methods used to compare Ensembl and Inparanoid species projections. """ #---------------------------------------------------------------------------------------------------------------------- @@ -10,6 +10,12 @@ import os import sys import argparse +#---------------------------------------------------------------------------------------------------------------------- +# globals +#---------------------------------------------------------------------------------------------------------------------- +ens_map = {} +inp_map = {} + #---------------------------------------------------------------------------------------------------------------------- # classes #---------------------------------------------------------------------------------------------------------------------- @@ -38,13 +44,13 @@ class switch(object): #---------------------------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------------------------- -def ens_map(input_file, output_file, recip_id) : +def create_ens_map(ortho_path, rap_map_path, recip_id) : #---------------------------------------------------------------------------------------------------------------------- """ open the ensemble plants and rap::irgsp mapping files and generate a 2-col mapping of PRJ to LOC loci where reciprocal identity is >= param% and confidence is high """ - + """ count_loc = 0 count_prj = 0 dict_ens_ids = {} @@ -80,14 +86,14 @@ def ens_map(input_file, output_file, recip_id) : #OS_2_PRJ_MAP.close() return [{"Unique Os loci: ": str(count_loc)}, {"Total projected loci:": str(count_prj)}] - + """ #---------------------------------------------------------------------------------------------------------------------- -def inp_map(input_file, output_file) : +def create_inp_map(ortho_path) : #---------------------------------------------------------------------------------------------------------------------- """ open the inparanoid file and generate a 2-col mapping of PRJ to LOC loci """ - + """ count_loc = 0 count_prj = 0 dict_inp_ids = {} @@ -117,7 +123,7 @@ def inp_map(input_file, output_file) : return [{"Unique Os loci:": str(count_loc)}, {"Total projected loci:": str(count_prj)}] #---------------------------------------------------------------------------------------------------------------------- -def compare_maps(input_file, output_file) : +def compare_maps(ensembl_map, inparanoid_map, output_path) : #---------------------------------------------------------------------------------------------------------------------- """compare Ensembl and Inparanoid projection results""" @@ -197,7 +203,7 @@ def compare_maps(input_file, output_file) : {"Total common projected loci:": str(total_common_prj)}, {"Avg. inclusive common projected loci:": str(avg_inc_prj_overlap)}, {"Avg. common projected loci:": str(avg_prj_overlap)}] - + """ #---------------------------------------------------------------------------------------------------------------------- # main #---------------------------------------------------------------------------------------------------------------------- @@ -205,36 +211,21 @@ def compare_maps(input_file, output_file) : # process args parser = argparse.ArgumentParser(description='Script with different analysis methods used to compare Ensembl and Inparanoid species projections.') +parser.add_argument('-e', '--ensembl_input_path', help='ensembl compara input file') +parser.add_argument('-i', '--inparanoid_input_path', help='inparanoid supercluster input file') +parser.add_argument('-m', '--rap_map_path', help='MSU-RAP mapping file') parser.add_argument('-r', '--reciprocal_id', type=int, help='reciprocal identity percentage') -parser.add_argument('-e', '--ensembl_input', help='ensmbl input file') -parser.add_argument('-i', '--inparanoid_input', help='inparanoid input file') -parser.add_argument('-o', '--output', help='destination output file') +# TODO: add an "inparanoid super-cluster vs. conventional input" flag + +parser.add_argument('-c', '--comparison_file_path', help='output file containing statistical comparisons') args = parser.parse_args() print args.accumulate(args.integers) -input_file = -output_file = -map_source_type = -recip_id = sys.argv[4] - - -list_counts = [] - -for case in switch(map_source_type): - if case("ens"): - list_counts = ens_map(input_file, output_file, recip_id) - break - if case("inp"): - list_counts = inp_map(input_file, output_file) - break - if case("compare"): - list_counts = compare_maps(input_file, output_file) # input_file is actually two comma-del input files (ens 1st, inp 2nd) - break - if case(): # default, could also just omit condition or 'if True' - print "Must provide a valid map source type: 'ens' (Ensembl), 'inp' (Inparanoid), or 'compare'" - -for item in list_counts : - for k, v in item.iteritems(): - print k, v +# create projection maps +ens_map = create_ens_map(args.ensembl_input_path, args.rap_map_path, args.reciprocal_id) +inp_map = create_inp_map(args.inparanoid_input_path) + +# generate stats and output them +compare_maps(ens_map, inp_map, comparison_file_path) -- 2.34.1