# HG changeset patch # User brenninc # Date 1463060895 14400 # Node ID 58ad7b5125900a1e75515d7a35bfb19cba2aff4a Uploaded diff -r 000000000000 -r 58ad7b512590 name_changer.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/name_changer.py Thu May 12 09:48:15 2016 -0400 @@ -0,0 +1,102 @@ +#!/usr/bin/env python + +import optparse +import os.path + + +def fix_header_line(start_header, header_line, new_names): + header_parts = header_line.split("\t") + if len(header_parts) <= len(start_header): + raise Exception("Only found {0} columns in second (header) line expected at least {1}.".format(len(header_parts), (len(start_header) + 1))) + data_headers = header_parts[:len(start_header)] + if data_headers != start_header: + raise Exception("Unexpected start to second (header) line Found: ") + new_header = "\t".join(start_header) + file_headers = header_parts[len(start_header):] + if len(file_headers) != len(new_names): + raise Exception("Found {0} file columns in header line, but {1} new_name paramters provided.".format(len(file_headers), len(new_names))) + for i in range(len(file_headers)): + new_header += "\t" + new_header += new_names[i] + new_header += "\n" + return new_header + + +def clean_names(prefix, old_names): + if len(old_names) > 1: + shared_start = old_names[0].strip() + shared_ends = old_names[0].strip() + for name in old_names: + clean = name.strip() + while len(shared_start) > 0 and (not clean.startswith(shared_start)): + shared_start = shared_start[:-1] + while len(shared_ends) > 0 and (not clean.endswith(shared_ends)): + shared_ends = shared_ends[1:] + start = len(shared_start) + end = 0 - len(shared_ends) + else: + start = 0 + end = 0 + new_names = [] + if end < 0: + for name in old_names: + new_names.append(prefix + name.strip()[start:end]) + else: + for name in old_names: + new_names.append(prefix + name.strip()[start:]) + return new_names + + +def main(): + #Parse Command Line + parser = optparse.OptionParser() + parser.add_option("--raw_count_file", action="store", type="string", default=None, help="path to file original with the counts") + parser.add_option("--fixed_count_file", action="store", type="string", default=None, help="new path for renamaned counts file") + parser.add_option("--raw_summary_file", action="store", type="string", default=None, help="path to file original with the summary") + parser.add_option("--fixed_summary_file", action="store", type="string", default=None, help="new path for renamaned summary file") + parser.add_option("--names_file", action="store", type="string", default=None, help="path to file which contains the names.") + parser.add_option("--new_name", action="append", type="string", default=None, + help="Names to be used. Must be the same length as in the raw_count_file") + parser.add_option("--names_prefix", action="store", type="string", default="", help="Prefix to add in from of every name.") + + (options, args) = parser.parse_args() + + if not os.path.exists(options.raw_count_file): + parser.error("Unable to find raw_count_file {0}.".format(options.raw_count_file)) + if options.names_file: + if options.new_name: + parser.error("names_file parameter clashes with new_names paramter(s)") + if not os.path.exists(options.names_file): + parser.error("Unable to find names_file {0}.".format(options.names_file)) + new_names = [] + with open(options.names_file, "r") as names_file: + for line in names_file: + new_names.append(line.strip()) + new_names = clean_names(options.names_prefix, new_names) + else: + if not options.new_name: + parser.error("No names_file or new_name paraters provided.") + new_names = options.new_name + + print "Changing column names to ", new_names + + with open(options.raw_count_file, "r") as input_file: + with open(options.fixed_count_file, "w") as output_file: + input_file.readline() # job line + start_header = ["Geneid", "Chr", "Start", "End", "Strand", "Length"] + header_line = fix_header_line(start_header, input_file.readline(), new_names) + output_file.write(header_line) + for line in input_file: + output_file.write(line) + + with open(options.raw_summary_file, "r") as input_file: + with open(options.fixed_summary_file, "w") as output_file: + start_header = ["Status"] + header_line = fix_header_line(start_header, input_file.readline(), new_names) + output_file.write(header_line) + for line in input_file: + output_file.write(line) + + +if __name__ == "__main__": + main() diff -r 000000000000 -r 58ad7b512590 subread_featurecounts.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/subread_featurecounts.xml Thu May 12 09:48:15 2016 -0400 @@ -0,0 +1,174 @@ + + Runs FeatureCount from subread + + subread + + + + + + + featureCounts -p -t exon -g gene_id + #if $reference_source.reference_source_selector=='history': + -a $reference_source.ref_file + #end if + #if $reference_source.reference_source_selector=='cached': + -a $reference_source.ref_path.fields.path + #end if + -o counts + #if $names_source.names_source_selector=='manual': + #for $s in $names_source.input_serie + $s.input_file + #end for + #else + #for $input in $names_source.inputs + "${input}" + #end for + #end if + ; + #if $names_source.names_source_selector in ["file","manual"]: + python $__tool_directory__/name_changer.py + --raw_count_file counts --fixed_count_file ${output} + --raw_summary_file counts.summary --fixed_summary_file "${summary}" + #if $names_source.names_source_selector=='file': + --names_file ${names_source.names_file} + #if $names_source.names_prefix: + --names_prefix ${names_source.names_prefix} + #end if + #else: + #for $s in $names_source.input_serie + --new_name $s.new_name + #end for + #end if + #else + cp counts "${output}" ; + cp counts.summary "${summary}" + #end if + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @misc{ + Subread, + author = {Liao Y, Smyth GK and Shi W}, + title = {Subread (incl FeatureCount on SourceForge}, + url = {http://subread.sourceforge.net/} + } + + 10.1093/bioinformatics/btt656 + 10.1093/nar/gkt214 + + + diff -r 000000000000 -r 58ad7b512590 tool-data/gene_transfer.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/gene_transfer.loc.sample Thu May 12 09:48:15 2016 -0400 @@ -0,0 +1,14 @@ +#This file lists the locations and dbkeys of all the gene transfer files + +#This file has the format (white space characters are TAB characters): +# +# +# +#So, gene_transfer.loc could look something like this: +# +#vm5 vm5 vM5 annotation /path/to/vM5.annotation.gtf +# +#Your gene_transfer.loc file should contain an entry for each individual +#gtf file. +# + diff -r 000000000000 -r 58ad7b512590 tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Thu May 12 09:48:15 2016 -0400 @@ -0,0 +1,7 @@ + + + + value, dbkey, name, path + +
+
diff -r 000000000000 -r 58ad7b512590 tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_dependencies.xml Thu May 12 09:48:15 2016 -0400 @@ -0,0 +1,6 @@ + + + + + +