# HG changeset patch # User yating-l # Date 1529954958 14400 # Node ID 8fdd3e06e1ece34c41ab2e162b2fc94fe53757d6 # Parent 0d13e4410c3da457f1053931a5ee56cbe0ef1611 planemo upload commit eb7c6866b218a41d9b22255ee6afb83551a5ff40 diff -r 0d13e4410c3d -r 8fdd3e06e1ec rename.py --- a/rename.py Mon Jun 18 18:36:00 2018 -0400 +++ b/rename.py Mon Jun 25 15:29:18 2018 -0400 @@ -3,10 +3,8 @@ """ import sys import csv -from collections import OrderedDict def rename(inputfile, outputfile, writer): - namemap = OrderedDict() with open(outputfile, 'w') as out: with open(inputfile, 'r') as rf: lines = rf.readlines() @@ -15,20 +13,17 @@ if ">" in line: oldname = line[1:].rstrip() newname = "scaffold_" + str(i) - line = ">" + newname + line = ">" + newname + "\n" i = i+1 writer.writerow([oldname, newname]) - #TODO: Add line breaks to chromosome sequences that are in a single line - out.write(line.rstrip() + "\n") + out.write(line) def main(): inputfile = str(sys.argv[1]) outputfile = str(sys.argv[2]) indexfile = str(sys.argv[3]) csvfile = open(indexfile, 'w') - fieldnames = ['Original sequence name', 'Renamed sequence name'] writer = csv.writer(csvfile) - writer.writerow(fieldnames) rename(inputfile, outputfile, writer) if __name__ == "__main__": diff -r 0d13e4410c3d -r 8fdd3e06e1ec rename_scaffold.xml --- a/rename_scaffold.xml Mon Jun 18 18:36:00 2018 -0400 +++ b/rename_scaffold.xml Mon Jun 25 15:29:18 2018 -0400 @@ -1,5 +1,5 @@ - - Rename the scaffolds so that they won't exceed 31 characters + + a Galaxy tool to rename the scaffolds in the reference genome so that they won't exceed 31 characters @@ -22,7 +22,7 @@ diff -r 0d13e4410c3d -r 8fdd3e06e1ec test-data/Dbia3_index.csv --- a/test-data/Dbia3_index.csv Mon Jun 18 18:36:00 2018 -0400 +++ b/test-data/Dbia3_index.csv Mon Jun 25 15:29:18 2018 -0400 @@ -1,4 +1,3 @@ -Original sequence name,Renamed sequence name contig1,scaffold_1 contig2,scaffold_2 contig3,scaffold_3