view unfold_column.py @ 2:616efa22d193 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/text_processing commit 369e40078146d00608d52205bb8cee66ae735b76-dirty
author bgruening
date Tue, 30 Jun 2015 17:47:23 -0400
parents 5314e5d6f040
children 37e1eb05b1b4
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()