#! /usr/bin/env python3

import sys
import os
import glob

if len(sys.argv)!=2:
    print ("Script has 1 parameter: directory with FASTA files")
    sys.exit(-1)

dir_fn=sys.argv[1]

os.chdir(dir_fn)
fa_fns=glob.glob("*.reduced.fa")
fa_fns.sort()
for fn in fa_fns:
    print("Processing '{}'".format(fn), file=sys.stderr)

    parts=fn.split(".")
    contig=parts[0]

    with open(fn) as f:
        for x in f:
            x=x.strip()
            if x=="":
                continue
            if x[0]==">":
                print (">{}_{}".format(contig,x[1:]))
            else:
                print(x)



@@ -73,20 +73,17 @@
 gv)!=2:%0A
-    
+%09
 print (%22
@@ -135,20 +135,17 @@
 files%22)%0A
-    
+%09
 sys.exit
@@ -252,20 +252,17 @@
 fa_fns:%0A
-    
+%09
 print(%22P
@@ -311,57 +311,45 @@
 r)%0A%0A
-    parts=fn.split(%22.%22)%0A    contig=parts%5B0%5D%0A%0A    
+%09node=fn.replace(%22.reduced.fa%22,%22%22)%0A%0A%09
 with
@@ -364,24 +364,18 @@
 ) as f:%0A
-        
+%09%09
 for x in
@@ -382,121 +382,74 @@
  f:%0A
-            x=x.strip()%0A            if x==%22%22:%0A                continue%0A            if x%5B0%5D==%22%3E%22:%0A                
+%09%09%09x=x.strip()%0A%09%09%09if len(x)==0:%0A%09%09%09%09continue%0A%09%09%09if x%5B0%5D==%22%3E%22:%0A%09%09%09%09
 prin
@@ -471,14 +471,12 @@
 mat(
-contig
+node
 ,x%5B1
@@ -484,42 +484,21 @@
 %5D))%0A
-            else:%0A                
+%09%09%09else:%0A%09%09%09%09
 prin

Fix node name detection