view spring_package/DBKit.py @ 38:80a4b98121b6 draft

"planemo upload commit 22cd6b0fa88ce0ddc4052beab306f5ba10754f12"
author guerler
date Wed, 25 Nov 2020 17:38:24 +0000
parents 0be0af9e695d
children 172398348efd
line wrap: on
line source

def createFile(identifier, databaseIndex, database, outputName):
    start = -1
    size = 0
    with open(databaseIndex) as file:
        for line in file:
            cols = line.split()
            if identifier == cols[0]:
                start = int(cols[1])
                size = int(cols[2])
                break
    if start != -1 and size > 0:
        with open(database) as file:
            file.seek(start)
            content = file.read(size)
            outputFile = open(outputName, "w")
            outputFile.write(content)
            outputFile.close()
        return True
    else:
        return False