changeset 1:061c3402a977 draft

"planemo upload for repository https://github.com/brinkmanlab/galaxy-tools/tree/master/make_unique_id commit b661895b5e2dff7235eb32476602c3b93411a42e"
author brinkmanlab
date Mon, 15 Jun 2020 18:48:27 -0400
parents a3a09dd8d09a
children c8bda09480ae
files make_unique_id.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/make_unique_id.py	Fri Jan 24 17:38:28 2020 -0500
+++ b/make_unique_id.py	Mon Jun 15 18:48:27 2020 -0400
@@ -29,20 +29,22 @@
     ids = defaultdict(int)
     
     def makeUnique(seq):
-        count = ids[seq.id]
-        ids[seq.id] += 1
+        newid = seq.id[:28] # Genbank has a max length for the id and sequence length number, truncate the sequence id if too long
+        count = ids[newid]
+        ids[newid] += 1
         if count:
             suffix = "_" + str(count)
-            newid = seq.id
             seqlenlen = len(str(len(seq)))
             if len(newid) + len(suffix) + 1 + seqlenlen > 28:
-                # Genbank has a max length for the id and sequence length number, truncate the sequence id if too long
                newid = newid[:27 - seqlenlen - len(suffix)]
 
-            print(f"{seq.id}\t{newid}{suffix}")
-            seq.id = newid + suffix
+            newid += suffix
             seq.name += suffix
 
+        if seq.id != newid:
+            print(f"{seq.id}\t{newid}")
+
+        seq.id = newid
         return seq