# HG changeset patch # User guerler # Date 1606388751 0 # Node ID 987e55ea29b8225ee47398c221803fc334b80f86 # Parent 1914107cc967cd10a651a5ad3a095295ea990dec "planemo upload commit ce9026535c3c6da5e97366a4f0b347b0ec572dbc-dirty" diff -r 1914107cc967 -r 987e55ea29b8 dbkit_create.py --- a/dbkit_create.py Wed Nov 25 17:22:48 2020 +0000 +++ b/dbkit_create.py Thu Nov 26 11:05:51 2020 +0000 @@ -1,7 +1,7 @@ #! /usr/bin/env python3 import argparse from os import system -from os.path import getsize +from os.path import isfile, getsize def getIdentifiers(args): @@ -28,22 +28,25 @@ logFile.write("Found %s entries.\n" % len(entries)) outputIndex = args.index outputDatabase = args.database - tempPath = args.temp.rstrip("/") - tempFile = "%s/temp.pdb" % tempPath - system("mkdir -p %s" % tempPath) system("rm -f %s" % outputDatabase) indexFile = open(outputIndex, 'w') start = 0 for entryId in entries: logFile.write("Loading %s.\n" % entryId) - system("wget -q -O %s %s%s" % (tempFile, args.url, entryId)) - tempSize = getsize(tempFile) - if tempSize == 0: - logFile.write("Entry `%s` not found.\n" % entryId) + if args.url: + fileName = "temp.dat" + system("wget -q -O %s %s%s" % (fileName, args.url, entryId)) else: - indexFile.write("%s\t%d\t%d\n" % (entryId, start, tempSize)) - start = start + tempSize + 1 - system("cat %s >> %s" % (tempFile, outputDatabase)) + pathName = args.path.rstrip("/") + fileName = "%s/%s" % (pathName, entryId) + if isfile(fileName): + size = getsize(fileName) + if size == 0: + logFile.write("Entry `%s` not found.\n" % entryId) + else: + indexFile.write("%s\t%d\t%d\n" % (entryId, start, size)) + start = start + size + system("cat %s >> %s" % (fileName, outputDatabase)) logFile.flush() logFile.close() @@ -51,8 +54,8 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description='DBKit - Download and Merge files into a single file.') parser.add_argument('-l', '--list', help='List of entries', required=True) - parser.add_argument('-u', '--url', help='Source Url', required=True) - parser.add_argument('-t', '--temp', help='temp', required=True) + parser.add_argument('-u', '--url', help='Source Url', required=False) + parser.add_argument('-p', '--path', help='Path to files', required=False) parser.add_argument('-il', '--idlength', help='Format Identifier Length (integer)', required=False, default="0") parser.add_argument('-ic', '--idcase', help='Format Identifier Case (lower, upper)', required=False, default=None) parser.add_argument('-ie', '--idextension', help='Format Identifier Extension', required=False, default=None) diff -r 1914107cc967 -r 987e55ea29b8 dbkit_create.xml --- a/dbkit_create.xml Wed Nov 25 17:22:48 2020 +0000 +++ b/dbkit_create.xml Thu Nov 26 11:05:51 2020 +0000 @@ -2,7 +2,7 @@ database generator diff -r 1914107cc967 -r 987e55ea29b8 test-data/create/index.ffindex --- a/test-data/create/index.ffindex Wed Nov 25 17:22:48 2020 +0000 +++ b/test-data/create/index.ffindex Thu Nov 26 11:05:51 2020 +0000 @@ -1,11 +1,11 @@ 6vyb.pdb 0 2088828 -6vyo.pdb 2088829 758727 -6w37.pdb 2847557 66582 -6w4h.pdb 2914140 675378 -6w9c.pdb 3589519 1250964 -6w9q.pdb 4840484 182574 -6wey.pdb 5023059 436995 -6wji.pdb 5460055 983583 -6wlc.pdb 6443639 1054296 -7bqy.pdb 7497936 448173 -7bv2.pdb 7946110 773145 +6vyo.pdb 2088828 758727 +6w37.pdb 2847555 66582 +6w4h.pdb 2914137 675378 +6w9c.pdb 3589515 1250964 +6w9q.pdb 4840479 182574 +6wey.pdb 5023053 436995 +6wji.pdb 5460048 983583 +6wlc.pdb 6443631 1054296 +7bqy.pdb 7497927 448173 +7bv2.pdb 7946100 773145