def decrypt_database_0(path_, file_, file_d_): buf=open(path_+"pub.txt",'rb') pub=pickle.load(buf) buf.close() buf=open(path_+"priv.txt",'rb') priv=pickle.load(buf) buf.close() in_ = open(path_+file_, 'r') n, m =in_.readline().split() n=int(n) m=int(m)/2 out_ =open(path_+file_d_, 'w') for x in range(n): for y in range(0, 2*m, 2): a=decrypt(priv,pub, mpz(in_.readline())) b=decrypt(priv,pub, mpz(in_.readline())) letter='' if a==0 and b==0: letter='A' elif a==0 and b==1: letter='C' elif a==1 and b==0: letter='G' elif a==1 and b==1: letter='T' # print letter, out_.write(letter) # print out_.write("\n") out_.close() in_.close() return file_d_
def decrypt_database_0(path_, file_, file_d_): buf = open(path_ + "pub.txt", "rb") pub = pickle.load(buf) buf.close() buf = open(path_ + "priv.txt", "rb") priv = pickle.load(buf) buf.close() in_ = open(path_ + file_, "r") n, m = in_.readline().split() n = int(n) m = int(m) / 2 out_ = open(path_ + file_d_, "w") for x in range(n): for y in range(0, 2 * m, 2): a = decrypt(priv, pub, mpz(in_.readline())) b = decrypt(priv, pub, mpz(in_.readline())) letter = "" if a == 0 and b == 0: letter = "A" elif a == 0 and b == 1: letter = "C" elif a == 1 and b == 0: letter = "G" elif a == 1 and b == 1: letter = "T" # print letter, out_.write(letter) # print out_.write("\n") out_.close() in_.close() return file_d_
def decrypt_database_1(path_, file_, file_d_): buf=open(path_+"pub.txt",'rb') pub=pickle.load(buf) buf.close() buf=open(path_+"priv.txt",'rb') priv=pickle.load(buf) buf.close() in_ = open(path_+file_, 'r') n, m =in_.readline().split() n=int(n) m=int(m)/4 # for x in hA: # print x out_ =open(path_+file_d_, 'w') for x in range(n): for y in range(m): # we stop as soon as we find a 1 if decrypt(priv, pub, mpz(in_.readline()))==1: out_.write('A') in_.readline() in_.readline() in_.readline() # print 'A', elif decrypt(priv, pub, mpz(in_.readline()))==1: out_.write('C') in_.readline() in_.readline() # print 'C', elif decrypt(priv, pub, mpz(in_.readline()))==1: out_.write('G') in_.readline() # print 'G', else:# decrypt(priv, pub, mpz(in_.readline()))==1: # this is a 'G' for sure, no need to decrypt in_.readline() out_.write('T') # print 'T', out_.write("\n") # print out_.close() in_.close() return file_d_
def decrypt_query_res(res, path_): buf=open(path_+"pub.txt",'rb') pub=pickle.load(buf) buf.close() buf=open(path_+"priv.txt",'rb') priv=pickle.load(buf) buf.close() dres=[0]*len(res) for i in range(len(res)): dres[i]=decrypt(priv, pub, res[i]) return dres