view unfold_column.py @ 6:8928e6d1e7ba draft

Uploaded
author bgruening
date Thu, 08 Jan 2015 09:07:31 -0500
parents 56e80527c482
children c78b1767db2b
line wrap: on
line source

#!/usr/bin/env python

import sys

out = open(sys.argv[4], 'w+')

with open(sys.argv[1]) as handle:
    for line in handle:
        cols = line.split('\t')
        unfolding_column = int(sys.argv[2]) - 1
        column_content = cols[ unfolding_column ]
        for elem in column_content.split( sys.argv[3] ):
            out.write( '\t'.join( cols[:unfolding_column] + [elem] + cols[unfolding_column+1:]) )
out.close()