Skip to content
Snippets Groups Projects
main.py 1.85 KiB
Newer Older
# created by Nina Marthe 2023 - nina.marthe@ird.fr
from Functions_output 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_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:
        args.target.append(line.split()[1])

for target_genome in args.target:
    segments_on_target_genome={}
    # 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!="" :
            file_path=args.segment_coordinates_path+file
            get_segments_positions_on_genome(file_path)
            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)