<s> import os <EOL> import sys <EOL> from taolib . CoreLib . Parser import WiggleIO <EOL> from taolib . CoreLib . FeatIO import WigTrackI <EOL> def main ( ) : <EOL> if len ( sys . argv ) < <NUM_LIT:3> : <EOL> sys . stderr . write ( "<STR_LIT>" ) <EOL> sys . stderr . write ( "<STR_LIT>" % os . path . basename ( sys . argv [ <NUM_LIT:0> ] ) ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> wigfhd = open ( sys . argv [ <NUM_LIT:1> ] ) <EOL> prefix = sys . argv [ <NUM_LIT:2> ] <EOL> wigtrack = WiggleIO . WiggleIO ( wigfhd ) . build_wigtrack ( ) <EOL> wigtrack . sort ( ) <EOL> for chrom in wigtrack . get_chr_names ( ) : <EOL> wig_chr = wigtrack . get_data_by_chr ( chrom ) <EOL> newwigtrack = WigTrackI ( ) <EOL> newwigtrack . span = wigtrack . span <EOL> ( wig_chr_p , wig_chr_s ) = wig_chr <EOL> for i in range ( len ( wig_chr_p ) ) : <EOL> newwigtrack . add_loc ( chrom , wig_chr_p [ i ] , wig_chr_s [ i ] ) <EOL> newwigfile = sys . argv [ <NUM_LIT:2> ] + "<STR_LIT:.>" + chrom + "<STR_LIT>" <EOL> newwigfhd = open ( newwigfile , "<STR_LIT:w>" ) <EOL> newwigtrack . write_wig ( newwigfhd , name = "<STR_LIT>" % chrom ) <EOL> newwigfhd . close ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
