diff --git a/DCC/CombineCounts.py b/DCC/CombineCounts.py index d6ac09e..5bc3901 100644 --- a/DCC/CombineCounts.py +++ b/DCC/CombineCounts.py @@ -143,8 +143,7 @@ def combine(self, Alist, col=7, circ=True): res.setdefault(line_nr, ['\t'.join(line_split[:3]+[line_split[5]])]).append(line_split[col - 1]) else: # input are host gene counts - res.setdefault(line_nr, ['\t'.join(line_split[:3]+[line_split[5]])]).append(line_split[col - 1]) - + res.setdefault(line_nr, ['\t'.join(line_split[:3])]).append(line_split[col - 1]) return res def writeouput(self, output, res, samplelist=None, header=False): @@ -155,3 +154,12 @@ def writeouput(self, output, res, samplelist=None, header=False): for line_nr in sorted(res): outfile.write("%s\n" % '\t'.join(res[line_nr])) outfile.close() + + def writeouput_linear(self, output, res, samplelist=None, header=False): + # Sample list is a string with sample names seperated by \t. + outfile = open(output, 'w') + if header: + outfile.write('Chr\tStart\tEnd\t' + samplelist + '\n') + for line_nr in sorted(res): + outfile.write("%s\n" % '\t'.join(res[line_nr])) + outfile.close() diff --git a/DCC/main.py b/DCC/main.py index ebf5ea5..1312daa 100644 --- a/DCC/main.py +++ b/DCC/main.py @@ -440,7 +440,7 @@ def main(): # Combine all to a individual sample host gene count to a single table res = cm.combine(linearfiles, col=6, circ=False) - cm.writeouput(output_linear_counts, res, samplelist, header=True) + cm.writeouput_linear(output_linear_counts, res, samplelist, header=True) logging.info("Finished combine individual linear gene expression counts") if not options.temp: