changeset 1:987e55ea29b8 draft

"planemo upload commit ce9026535c3c6da5e97366a4f0b347b0ec572dbc-dirty"
author guerler
date Thu, 26 Nov 2020 11:05:51 +0000
parents 1914107cc967
children 81c7d4668a7e
files dbkit_create.py dbkit_create.xml test-data/create/index.ffindex
diffstat 3 files changed, 27 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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 @@
     <description>database generator</description>
     <command detect_errors="exit_code"><![CDATA[
         mkdir temp &&
-        python3 '$__tool_directory__/dbkit_create.py' -l '$input' -u '$url' -t 'temp' -o '$index' -d '$database' -g '$log' -il '$advanced.idlength' -ic '$advanced.idcase' -ie '$advanced.idextension'
+        python3 '$__tool_directory__/dbkit_create.py' -l '$input' -u '$url' -o '$index' -d '$database' -g '$log' -il '$advanced.idlength' -ic '$advanced.idcase' -ie '$advanced.idextension'
     ]]></command>
     <inputs>
         <param format="tabular" name="input" type="data" label="List of Identifiers" help="Specify a list containing all entry identifiers to be downloaded."/>
--- 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