# created by Nina Marthe 2023 - nina.marthe@ird.fr # licensed under MIT import os import subprocess from Graph_gff import * from Functions_output import * from argparser import * #from inference import * args=arg() read_args(args) # intersect is in the current directory intersect="intersect" gfa=args.graph.name load_intersect(intersect) # outputs the gff and gaf of the graph for chr10 out_graph_gff=gfa.split("/")[-1].split(".")[0:-1][0]+".gff" out_graph_gaf=gfa.split("/")[-1].split(".")[0:-1][0]+".gaf" segments=args.segment_coordinates_path+"/segments.txt" graph_gff(out_graph_gff) graph_gaf(out_graph_gaf,segments) segment_coord_files=os.listdir(args.segment_coordinates_path) # get list of files in seg_coord. # get the target genomes if there is none specified if len(args.target)==0: walks=open(args.segment_coordinates_path+"/walks.txt",'r') walk_lines=walks.readlines() for line in walk_lines: genome_name=line.split()[1] if (args.source_genome not in genome_name) & (genome_name not in args.target) & ("MINIGRAPH" not in genome_name): args.target.append(genome_name) for target_genome in args.target: segments_on_target_genome={} print(f'{target_genome} transfer :') # create directory to store output files command="mkdir "+target_genome subprocess.run(command,shell=True,timeout=None) # create dictonaries with paths and segments positions. for file in segment_coord_files: genome_name=get_genome_name(args.target,file) if genome_name==target_genome : print(f' loading the information from the file {file}') file_path=args.segment_coordinates_path+file get_segments_positions_on_genome(file_path) print(f' loading the walks for the genome {target_genome}') walks_path=args.segment_coordinates_path+"/walks.txt" target_genome_paths=get_paths(walks_path,target_genome) out_target_gff=target_genome+"/"+target_genome+".gff" out_target_var=target_genome+"/"+target_genome+"_var.txt" out_clustal=target_genome+"/"+target_genome+"_aln.txt" transfer_on_target(segments,out_target_gff,out_target_var,out_clustal,target_genome,target_genome_paths,args)