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=[]
|
||||
ldg=[]
|
||||
if arg[0]=='-d':
|
||||
if arg[4]=="-r":
|
||||
if arg[2]=="-r":
|
||||
c=0
|
||||
else:
|
||||
return a,d,ld,ldg
|
||||
return a,d,ld,ldg,dict(),dict()
|
||||
elif arg[0]=='-f':
|
||||
get_data_file(arg[1],dir)
|
||||
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)
|
||||
assert(len(a)==len(d))
|
||||
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)
|
||||
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.
|
||||
t=0
|
||||
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:
|
||||
continue
|
||||
t+=1
|
||||
if t>=save_after and update==0:
|
||||
t=0
|
||||
c+=1
|
||||
write_dict_json(name+str(c),"processed",lsytemp)
|
||||
lsytemp={}
|
||||
if t>=save_after:
|
||||
if enable_break==1:
|
||||
break
|
||||
if not update:
|
||||
c+=1
|
||||
write_dict_json(name+str(c),"processed",lsytemp)
|
||||
write_dict_json(name,"processed",lsy)
|
||||
return lsy
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import pandas as pd
|
|||
import json
|
||||
import os
|
||||
import gc
|
||||
import pickle
|
||||
from get_data import get_data_homology,get_data_genome
|
||||
from process_data import create_data_homology_ls
|
||||
|
||||
|
|
@ -20,13 +21,21 @@ if arg[-1]=="-test":
|
|||
|
||||
arg=arg[:-1]
|
||||
|
||||
if len(arg)!=5:
|
||||
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={}
|
||||
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"
|
||||
a_h,d_h=get_data_homology(arg,dir_hom)
|
||||
|
||||
|
|
@ -38,10 +47,10 @@ print("Data Read")
|
|||
n=3 #no. of numbers neighbors
|
||||
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("Neighbor Genes Updated Successfully")
|
||||
print("Neighbor Genes Updated Successfully.")
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import pandas as pd
|
|||
import json
|
||||
import os
|
||||
import gc
|
||||
import pickle
|
||||
from get_data import get_data_homology,get_data_genome
|
||||
from process_data import create_data_homology_ls
|
||||
|
||||
|
|
@ -20,12 +21,19 @@ if arg[-1]=="-test":
|
|||
|
||||
arg=arg[:-1]
|
||||
|
||||
if len(arg)!=5:
|
||||
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={}
|
||||
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")
|
||||
a_h=[]
|
||||
|
|
@ -37,6 +45,6 @@ print("Data Read")
|
|||
n=3 #no. of numbers neighbors
|
||||
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("Neighbor Genes Updated Successfully")
|
||||
Loading…
Reference in a new issue