<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _importSequence(chromosome, fastaFile, targetDir) :
    "Serializes fastas into .dat files"

    f = gzip.open(fastaFile)
    header = f.readline()
    strRes = f.read().upper().replace('\n', '').replace('\r', '')
    f.close()

    fn = '%s/chromosome%s.dat' % (targetDir, chromosome.number)
    f = open(fn, 'w')
    f.write(strRes)
    f.close()
    chromosome.dataFile = fn
    chromosome.header = header
    return len(strRes)