def __init__(self,out,lineLen=None,mode="w",compresslevel=6): if lineLen is None: lineLen = 1000 if not hasattr(out,'write'): out = openCompressed(out,mode,compresslevel=compresslevel) self.outClose = True else: self.outClose = False self.out = out self.lineLen = lineLen
def __init__(self,infile): """Ctor. @param infile It can be either a string with a file name, or it can be an iterator that returns lines (each line should be terminated with a new line), e.g. a file object. An iterator can be a filter that reads another FastaReader object, performs transformations on the records and emits them as lines.""" if is_string(infile): infile = openCompressed(infile,'r') self.ownInfile = True else: self.ownInfile = False self.infile = infile self.freshHdr = False self.maxLineLen = 0 self.seqTotal = 0 self.symbolsTotal = 0