# Path: seqio.py
# def fastaIterator(fh):
# 
#     l = fh.readline()
#     if(not l or not l.startswith(">")):
#         raise Exception("No \">\" at start of Fasta File")
#     name = l.strip()[1:]
#     seq = ""
#     while True:
#         l = fh.readline()
#         if not l or l.startswith(">"):
#             yield FastaRecord(name,seq)
#             if not l:
#                 break
#             name = l.strip()[1:]
#             seq = ""
#         else:
#             seq += l.strip()
# 
# Path: nucio.py
# def fileIterator(filename, itemIterator, open_func=open):
#     '''Handles the life cyle of a file,
#        The itemIterator will be passed the 
#        opened file handle
#     '''
#     with open_func(filename) as fh:
#         for item in itemIterator(fh):
#             yield item


import sys
from seqio import fastaIterator
from nucio import fileIterator
from itertools import repeat
#!/usr/bin/env python

#Outputs a genome's chromosome segments
# i.e. splits the genome according to the formula
# in the assembly complexity paper
#   no stretch of more than 1 million N's


if not len(sys.argv) == 2:
    sys.exit("reference_segments.py in.fa")



store_table = {'A':[],
         'C':[],
         'G':[],
         'T':[],
         'N':[]}

previous = 0
curr_count = 1
table = 2
accumulator = ["N",-1,store_table]    

def runs(acc, nxt):
    prev_letter = acc[previous]
    acc[curr_count] += 1
    if not prev_letter == nxt:
        if acc[curr_count] > 0:

# Path: seqio.py
# def fastaIterator(fh):
# 
#     l = fh.readline()
#     if(not l or not l.startswith(">")):
#         raise Exception("No \">\" at start of Fasta File")
#     name = l.strip()[1:]
#     seq = ""
#     while True:
#         l = fh.readline()
#         if not l or l.startswith(">"):
#             yield FastaRecord(name,seq)
#             if not l:
#                 break
#             name = l.strip()[1:]
#             seq = ""
#         else:
#             seq += l.strip()
# 
# Path: nucio.py
# def fileIterator(filename, itemIterator, open_func=open):
#     '''Handles the life cyle of a file,
#        The itemIterator will be passed the 
#        opened file handle
#     '''
#     with open_func(filename) as fh:
#         for item in itemIterator(fh):
#             yield item


# Path: reference_segments.py
import sys
from seqio import fastaIterator
from nucio import fileIterator
from itertools import repeat

#!/usr/bin/env python

#Outputs a genome's chromosome segments
# i.e. splits the genome according to the formula
# in the assembly complexity paper
#   no stretch of more than 1 million N's


if not len(sys.argv) == 2:
    sys.exit("reference_segments.py in.fa")



store_table = {'A':[],
         'C':[],
         'G':[],
         'T':[],
         'N':[]}

previous = 0
curr_count = 1
table = 2
accumulator = ["N",-1,store_table]    

def runs(acc, nxt):
    prev_letter = acc[previous]
    acc[curr_count] += 1
    if not prev_letter == nxt:
        if acc[curr_count] > 0:

            acc[table][prev_letter].append(acc[curr_count])