Esempio n. 1
0
def ReadSeqs3(FileName, OnSeq, ShowProgress=True):
    File = open(FileName)
    if ShowProgress:
        progress.InitFile(File, FileName)
    Label = ""
    Seq = ""
    while 1:
        Line = File.readline()
        if len(Line) == 0:
            if Seq != "":
                OnSeq(Label, Seq)
            if ShowProgress:
                print >> sys.stderr, "\n"
            return
        Line = Line.strip()
        if len(Line) == 0:
            continue
        if Line[0] == ">":
            if Seq != "":
                if ShowProgress:
                    progress.File()
                if TRUNC_LABELS:
                    Label = Label.split()[0]
                OnSeq(Label, Seq)
            Label = Line[1:]
            Seq = ""
        else:
            Seq += Line
Esempio n. 2
0
def ReadSeqs2(FileName, ShowProgress=True):
    Seqs = []
    Labels = []
    File = open(FileName)
    if ShowProgress:
        progress.InitFile(File, FileName)
    while 1:
        progress.File()
        Line = File.readline()
        if len(Line) == 0:
            if ShowProgress:
                print >> sys.stderr, "\n"
            return Labels, Seqs
        Line = Line.strip()
        if len(Line) == 0:
            continue
        if Line[0] == ">":
            Id = Line[1:]
            if TRUNC_LABELS:
                Id = Id.split()[0]
            Labels.append(Id)
            Seqs.append("")
        else:
            i = len(Seqs) - 1
            Seqs[i] = Seqs[i] + Line
Esempio n. 3
0
def ReadFile(argFileName, OnRecord, ShowProgress=True):
    global FileName
    FileName = argFileName
    File = open(FileName)

    if ShowProgress:
        progress.InitFile(File, FileName)
    while GetRec(File, OnRecord):
        if ShowProgress:
            progress.File()
    if ShowProgress:
        progress.FileDone()