#!/usr/bin/perl # ----------------------------------------------------------------------- # genpos2binary 1.0 # # This program creates a binary representation of a genpos file. # # # A genpos file has the following structure: # 2 5 # 8 10 # 12 15 # # The program produces an output file with the following content: # 011110011101111 # # # The first parameter tupel (2,5) produce the following output: 01111 (The index starts with 1 not with 0!) # The second parameter tupel (8,10) produce thw following output: 00111 # # # Copyright by Joern Hameister (2005) # ----------------------------------------------------------------------- if(@ARGV<2) { print "This program creates a binary representation of a genpos input file and writes the result to an output textfile.\nParameter 1: Inputfile\nParameter 2: Outputfile\nFor example: ./genpos2binary.pl ./inputfile.txt ./outputfile.txt\n"; } else { open(INPUT, "<" , @ARGV[0]); open(SINK, ">" , @ARGV[1]); $counter = 1; while() { @positions = split /\s+/, $_; for($i=$counter;$i<@positions[0];$i++) { print SINK 0; } $counter = @positions[0]; for($i=$counter;$i<=@positions[1];$i++) { print SINK 1; } $counter = @positions[1]+1; } }