<s> '''<STR_LIT>''' <EOL> import sys <EOL> import CGAT . Experiment as E <EOL> import CGAT . Fastq as Fastq <EOL> import gzip <EOL> def replace ( fastqfile , baseToReplace ) : <EOL> '''<STR_LIT>''' <EOL> outf = gzip . open ( "<STR_LIT>" + fastqfile , "<STR_LIT:w>" ) <EOL> fastq = gzip . open ( fastqfile ) <EOL> iterator = Fastq . iterate ( fastq ) <EOL> for record in iterator : <EOL> x = list ( record . seq ) <EOL> x [ int ( baseToReplace ) ] = "<STR_LIT:N>" <EOL> record . seq = "<STR_LIT>" . join ( x ) <EOL> outf . write ( "<STR_LIT:@>" + record . identifier + "<STR_LIT:\n>" + record . seq + <EOL> "<STR_LIT:\n>" + "<STR_LIT:+>" + record . identifier + "<STR_LIT:\n>" + record . quals + "<STR_LIT:\n>" ) <EOL> def main ( argv = None ) : <EOL> """<STR_LIT>""" <EOL> if not argv : <EOL> argv = sys . argv <EOL> parser = E . OptionParser ( version = "<STR_LIT>" , <EOL> usage = globals ( ) [ "<STR_LIT>" ] ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> ( options , args ) = E . Start ( parser , argv = argv ) <EOL> if not options . infile : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if not options . base_position : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> replace ( options . infile , options . base_position ) <EOL> E . Stop ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( sys . argv ) ) </s>
