##################################
#                                #
# Last modified 12/03/2014       # 
#                                #
# Georgi Marinov                 #
#                                # 
##################################

import sys

def run():

    if len(sys.argv) < 2:
        print 'usage: python %s fastq 1|2' % sys.argv[0]
        print '\tUse - for stdin; the script will print to stdout by default'
        print '\t1|2 referse to whether the input is read1 or read2'
        print '\tIf you want to replace spaces, use _space_ as the string character'
        sys.exit(1)

    fastq = sys.argv[1]
    end = sys.argv[2]

    i=0
    pos=1
    if fastq == '-':
        input_stream = sys.stdin
    else:
        input_stream = open(fastq)
    for line in input_stream:
        i+=1
        if pos==1 and line.startswith('@'):
            print '@' + line.strip().split(' ')[1] + '/' + end
            pos=2
            continue
        if pos==1 and line[0] != '@':
            print 'fastq broken'
            sys.exit(1)
        if pos==2:
            print line.strip()
            pos=3
            continue
        if pos==3:
            print '+'
            pos=4
            continue
        if pos==4:
            print line.strip()
            pos=1
            continue

run()

