Exemple #1
0
def ToFasta(dbFile, outputFile):
    """
    Opens the screed database file and attempts to dump it
    to a FASTA-formatted text file
    """
    outFile = open(outputFile, 'wb')
    db = ScreedDB(dbFile)
    for value in db.itervalues():
       ToFastaWrite(outFile, value) 
    db.close()
    outFile.close()
Exemple #2
0
def ToFastaRecs(dbFile, record_indices, outputFile=None, outFile=None):
    """Write individual records to a new FASTA-formatted file.

    """
    if outFile is None:
        outFile = open(outputFile, 'wb')
    db = ScreedDB(dbFile)
    for i in record_indices:
        value = db.loadRecordByIndex(i)
        ToFastaWrite(outFile, value)
    db.close()
    if outFile is None:
        outFile.close()
def ToFasta(dbFile, outputFile):
    """
    Opens the screed database file and attempts to dump it
    to a FASTA-formatted text file
    """
    outFile = open(outputFile, 'wb')
    db = ScreedDB(dbFile)

    for value in db.itervalues():
        outFile.write('>%s %s\n%s\n' % (value['name'], GetComments(value),
                                        linewrap(str(value['sequence']))))
    
    db.close()
    outFile.close()
Exemple #4
0
def ToFasta(dbFile, outputFile):
    """
    Opens the screed database file and attempts to dump it
    to a FASTA-formatted text file
    """
    outFile = open(outputFile, 'wb')
    db = ScreedDB(dbFile)

    for value in db.itervalues():
        outFile.write('>%s %s\n%s\n' % (value['name'], GetComments(value),
                                        linewrap(str(value['sequence']))))

    db.close()
    outFile.close()
Exemple #5
0
def read_fasta_sequences(filename):
    """
    Function to parse text from the given FASTA file into a screed database
    """
    import openscreed

    # Will raise an exception if the file doesn't exist
    iterfunc = openscreed.open(filename)

    # Create the screed db
    create_db(filename, fasta.FieldTypes, iterfunc)

    return ScreedDB(filename)
Exemple #6
0
def read_hava_sequences(filename):
    """
    Function to parse text from the given HAVA file into a screed database
    """
    # Will raise an exception if the file doesn't exist
    theFile = open(filename, "rb")

    # Setup the iterator function
    iterfunc = hava.hava_iter(theFile)

    # Create the screed db
    create_db(filename, hava.FieldTypes, iterfunc)
    theFile.close()

    return ScreedDB(filename)