Commit d40650e8 authored by Celine Noirot's avatar Celine Noirot
Browse files

does not start column index a 0

parent 114f8632
......@@ -32,7 +32,7 @@ __authors__ = "Celine Noirot"
__keywords__ = "Count matrix, join columns, merge files"
__description__ = "Merge (join) files columns on first column, skip lines starting with #"
def read_file (file,libname,dict_col, col_number=1):
def read_file (file,libname,dict_col, col_number=2):
"""
Extract count from the count file
@param file : the input count file (output of sam2count)
......@@ -71,7 +71,7 @@ parser = OptionParser(usage="Usage: %prog", description = "Merge files columns o
igroup = OptionGroup(parser, "Input options","")
igroup.add_option("-f", "--files", dest="files", help="tabulated files separated by ',' ")
igroup.add_option("-n", "--names", dest="names", help="matrix columns names in the same order as files ',' ")
igroup.add_option("-c", "--column", dest="col_number", help="column of each files to extract, first column is 0, default 1", default=1, metavar="INT")
igroup.add_option("-c", "--column", dest="col_number", help="column of each files to extract, first column is 1, default 2", default=2, metavar="INT")
parser.add_option_group(igroup)
ogroup = OptionGroup(parser, "Output files options","")
......@@ -85,8 +85,8 @@ if options.files == None :
parser.print_help()
sys.exit(1)
if options.col_number < 1 :
sys.stderr.write("Column must be greater than 0 \n")
if int(options.col_number) < 2 :
sys.stderr.write("Column must be greater than 1 \n")
parser.print_help()
sys.exit(1)
......@@ -107,6 +107,7 @@ if options.names :
parser.print_help()
sys.exit(1)
col_to_extract=int(options.col_number)-1
current_libname=""
for idx, line in enumerate(files):
file = line.rstrip()
......@@ -116,12 +117,12 @@ for idx, line in enumerate(files):
libs_name.append(current_libname)
else :
current_libname = libs_name[idx]
read_file(file,current_libname,dict_col,options.col_number)
read_file(file,current_libname,dict_col,col_to_extract)
else :
sys.stderr.write("File : " + file + " doesn't exist")
sys.exit(1)
fout = open (options.output,"w")
fout.write ( '#contig_name\t' + '\t'.join(libs_name) +"\n")
fout.write ( '#id\t' + '\t'.join(libs_name) +"\n")
# Pour tous les contigs : contruction de la ligne
for contig_name in sorted(dict_col.keys()) :
line = []
......@@ -132,4 +133,4 @@ for contig_name in sorted(dict_col.keys()) :
fout.write ( '\t'.join(line) +"\n")
fout.close
sys.exit(0)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment