<s> import sys <EOL> import pysam <EOL> import textwrap <EOL> import os <EOL> def print_header ( ) : <EOL> print textwrap . dedent ( """<STR_LIT>""" ) <EOL> if len ( sys . argv ) == <NUM_LIT:3> : <EOL> fa = pysam . Fastafile ( sys . argv [ <NUM_LIT:2> ] ) <EOL> print_header ( ) <EOL> logdir_files = os . listdir ( sys . argv [ <NUM_LIT:1> ] ) <EOL> for filename in logdir_files : <EOL> if filename . endswith ( '<STR_LIT>' ) : <EOL> with open ( sys . argv [ <NUM_LIT:1> ] + '<STR_LIT:/>' + filename , '<STR_LIT:r>' ) as logfile : <EOL> for line in logfile : <EOL> ref = '<STR_LIT>' <EOL> alt = '<STR_LIT>' <EOL> start = '<STR_LIT>' <EOL> info = [ ] <EOL> info . append ( '<STR_LIT>' ) <EOL> if line . startswith ( '<STR_LIT>' ) : <EOL> indelinfo = line . strip ( ) . split ( ) [ <NUM_LIT:1> ] . split ( '<STR_LIT::>' ) <EOL> if indelinfo [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> chrom , start , end = indelinfo [ <NUM_LIT:1> : <NUM_LIT:4> ] <EOL> ref = fa . fetch ( chrom , int ( start ) - <NUM_LIT:1> , int ( end ) ) . upper ( ) <EOL> alt = ref [ <NUM_LIT:0> ] . upper ( ) <EOL> if indelinfo [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> chrom , start , seq = indelinfo [ <NUM_LIT:1> : <NUM_LIT:4> ] <EOL> ref = fa . fetch ( chrom , int ( start ) - <NUM_LIT:1> , int ( start ) ) . upper ( ) <EOL> alt = ref . upper ( ) + seq . upper ( ) <EOL> assert ref != '<STR_LIT>' and alt != '<STR_LIT>' and start != '<STR_LIT>' <EOL> print '<STR_LIT:\t>' . join ( ( chrom , start , '<STR_LIT:.>' , ref , alt , '<STR_LIT:100>' , '<STR_LIT>' , '<STR_LIT:;>' . join ( info ) , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> else : <EOL> print "<STR_LIT>" , sys . argv [ <NUM_LIT:0> ] , "<STR_LIT>" </s>
