mirror of
https://github.com/Priyatham-sai-chand/compara-deep-learning.git
synced 2026-10-05 08:11:34 -07:00
Add files via upload
This commit is contained in:
parent
1168972b00
commit
81c967b5d4
5 changed files with 54 additions and 22 deletions
22
create_genome_maps.py
Normal file
22
create_genome_maps.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import pandas as pd
|
||||||
|
import requests
|
||||||
|
import sys
|
||||||
|
import pickle
|
||||||
|
from get_data import get_data_genome
|
||||||
|
|
||||||
|
arg=sys.argv
|
||||||
|
arg=arg[1:]
|
||||||
|
|
||||||
|
if len(arg)!=3:
|
||||||
|
print("No. of arguments more or less. Please check")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
dir_g="data"
|
||||||
|
cmap,cimap,ld,ldg,a,d=get_data_genome(arg,dir_g)
|
||||||
|
|
||||||
|
data=dict(cmap=cmap,cimap=cimap,ld=ld,ldg=ldg,a=a,d=d)
|
||||||
|
|
||||||
|
with open("genome_maps","wb") as file:
|
||||||
|
pickle.dump(data,file)
|
||||||
|
|
||||||
|
print("Genome Maps Created Successfully.")
|
||||||
|
|
@ -10,16 +10,16 @@ def get_data_genome(arg,dir):
|
||||||
ld=[]
|
ld=[]
|
||||||
ldg=[]
|
ldg=[]
|
||||||
if arg[0]=='-d':
|
if arg[0]=='-d':
|
||||||
if arg[4]=="-r":
|
if arg[2]=="-r":
|
||||||
c=0
|
c=0
|
||||||
else:
|
else:
|
||||||
return a,d,ld,ldg
|
return a,d,ld,ldg,dict(),dict()
|
||||||
elif arg[0]=='-f':
|
elif arg[0]=='-f':
|
||||||
get_data_file(arg[1],dir)
|
get_data_file(arg[1],dir)
|
||||||
elif arg[0]=="-nd":
|
elif arg[0]=="-nd":
|
||||||
return ld,ldg,a,d
|
return ld,ldg,a,d,dict(),dict()
|
||||||
|
|
||||||
if arg[4]=="-r":
|
if arg[2]=="-r":
|
||||||
a,d=read_data_genome(dir,a,d)
|
a,d=read_data_genome(dir,a,d)
|
||||||
assert(len(a)==len(d))
|
assert(len(a)==len(d))
|
||||||
print("Creating Maps:")
|
print("Creating Maps:")
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ def get_nearest_neighbors(g,gs,n,a,d,ld,ldg,cmap,cimap):
|
||||||
end=int(sldf.loc[itemp].end)
|
end=int(sldf.loc[itemp].end)
|
||||||
return ne,nr
|
return ne,nr
|
||||||
|
|
||||||
def create_data_homology_ls(a_h,d_h,n,a,d,ld,ldg,cmap,cimap,save_after,enable_break,update):
|
def create_data_homology_ls(a_h,d_h,n,a,d,ld,ldg,cmap,cimap,save_after,enable_break):
|
||||||
lsy={} #dictionary which stores +/- n genes of the given gene by id. Each key is a gene id which corresponds to the one in center.
|
lsy={} #dictionary which stores +/- n genes of the given gene by id. Each key is a gene id which corresponds to the one in center.
|
||||||
t=0
|
t=0
|
||||||
if os.path.exists("processed/neighbor_genes.json"):
|
if os.path.exists("processed/neighbor_genes.json"):
|
||||||
|
|
@ -161,15 +161,8 @@ def create_data_homology_ls(a_h,d_h,n,a,d,ld,ldg,cmap,cimap,save_after,enable_br
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
t+=1
|
t+=1
|
||||||
if t>=save_after and update==0:
|
if t>=save_after:
|
||||||
t=0
|
|
||||||
c+=1
|
|
||||||
write_dict_json(name+str(c),"processed",lsytemp)
|
|
||||||
lsytemp={}
|
|
||||||
if enable_break==1:
|
if enable_break==1:
|
||||||
break
|
break
|
||||||
if not update:
|
|
||||||
c+=1
|
|
||||||
write_dict_json(name+str(c),"processed",lsytemp)
|
|
||||||
write_dict_json(name,"processed",lsy)
|
write_dict_json(name,"processed",lsy)
|
||||||
return lsy
|
return lsy
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import pandas as pd
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import gc
|
import gc
|
||||||
|
import pickle
|
||||||
from get_data import get_data_homology,get_data_genome
|
from get_data import get_data_homology,get_data_genome
|
||||||
from process_data import create_data_homology_ls
|
from process_data import create_data_homology_ls
|
||||||
|
|
||||||
|
|
@ -20,13 +21,21 @@ if arg[-1]=="-test":
|
||||||
|
|
||||||
arg=arg[:-1]
|
arg=arg[:-1]
|
||||||
|
|
||||||
if len(arg)!=5:
|
if len(arg)!=3:
|
||||||
print("No. of arguments more or less. Please check")
|
print("No. of arguments more or less. Please check")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
dir_g="data"
|
data={}
|
||||||
cmap,cimap,ld,ldg,a,d=get_data_genome(arg,dir_g)
|
with open("genome_maps","rb") as file:
|
||||||
|
data=pickle.load(file)
|
||||||
|
cmap=data["cmap"]
|
||||||
|
cimap=data["cimap"]
|
||||||
|
ld=data["ld"]
|
||||||
|
ldg=data["ldg"]
|
||||||
|
a=data["a"]
|
||||||
|
d=data["d"]
|
||||||
|
|
||||||
|
print("Genome_Maps Loaded")
|
||||||
dir_hom="data_homology"
|
dir_hom="data_homology"
|
||||||
a_h,d_h=get_data_homology(arg,dir_hom)
|
a_h,d_h=get_data_homology(arg,dir_hom)
|
||||||
|
|
||||||
|
|
@ -38,10 +47,10 @@ print("Data Read")
|
||||||
n=3 #no. of numbers neighbors
|
n=3 #no. of numbers neighbors
|
||||||
save_after=5 #to save data after n steps
|
save_after=5 #to save data after n steps
|
||||||
|
|
||||||
lsy=create_data_homology_ls(a_h,d_h,n,a,d,ld,ldg,cmap,cimap,save_after,enable_break,1)
|
lsy=create_data_homology_ls(a_h,d_h,n,a,d,ld,ldg,cmap,cimap,save_after,enable_break)
|
||||||
print(len(lsy))
|
print(len(lsy))
|
||||||
|
|
||||||
print("Neighbor Genes Updated Successfully")
|
print("Neighbor Genes Updated Successfully.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import pandas as pd
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import gc
|
import gc
|
||||||
|
import pickle
|
||||||
from get_data import get_data_homology,get_data_genome
|
from get_data import get_data_homology,get_data_genome
|
||||||
from process_data import create_data_homology_ls
|
from process_data import create_data_homology_ls
|
||||||
|
|
||||||
|
|
@ -20,12 +21,19 @@ if arg[-1]=="-test":
|
||||||
|
|
||||||
arg=arg[:-1]
|
arg=arg[:-1]
|
||||||
|
|
||||||
if len(arg)!=5:
|
if len(arg)!=3:
|
||||||
print("No. of arguments more or less. Please check")
|
print("No. of arguments more or less. Please check")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
dir_g="data"
|
data={}
|
||||||
cmap,cimap,ld,ldg,a,d=get_data_genome(arg,dir_g)
|
with open("genome_maps","rb") as file:
|
||||||
|
data=pickle.load(file)
|
||||||
|
cmap=data["cmap"]
|
||||||
|
cimap=data["cimap"]
|
||||||
|
ld=data["ld"]
|
||||||
|
ldg=data["ldg"]
|
||||||
|
a=data["a"]
|
||||||
|
d=data["d"]
|
||||||
|
|
||||||
df=pd.read_hdf("negative_dataset.h5",key="ndf")
|
df=pd.read_hdf("negative_dataset.h5",key="ndf")
|
||||||
a_h=[]
|
a_h=[]
|
||||||
|
|
@ -37,6 +45,6 @@ print("Data Read")
|
||||||
n=3 #no. of numbers neighbors
|
n=3 #no. of numbers neighbors
|
||||||
save_after=5 #to save data after n steps
|
save_after=5 #to save data after n steps
|
||||||
|
|
||||||
lsy=create_data_homology_ls(a_h,d_h,n,a,d,ld,ldg,cmap,cimap,save_after,enable_break,1)
|
lsy=create_data_homology_ls(a_h,d_h,n,a,d,ld,ldg,cmap,cimap,save_after,enable_break)
|
||||||
print(len(lsy))
|
print(len(lsy))
|
||||||
print("Neighbor Genes Updated Successfully")
|
print("Neighbor Genes Updated Successfully")
|
||||||
Loading…
Reference in a new issue