#!/usr/bin/env python import sys from cafysis.file_io.ninfo import NinfoFile from cafysis.elements.ninfo import NinfoSet if len(sys.argv) != 3: print ('Usage: SCRIPT [input ninfo] [output ninfo]') sys.exit(2) ninfo = NinfoFile(sys.argv[1]) ninfo.open_to_read() ns = NinfoSet() ninfo.read_all(ns) ninfo.close() ns.update_info() ns.sort_by_mp() ns.reassign_id() ninfo = NinfoFile(sys.argv[-1]) ninfo.open_to_write() ninfo.write_all(ns) ninfo.close()
#linesp[4] # dist #if first: # delta1 = mp1 - 1 # delta2 = mp2 - 1 # first = False if side == 1: #aln[mp1 - delta1] = mp2 - delta2 aln[mp1] = mp2 elif side == 2: #aln[mp2 - delta2] = mp1 - delta1 aln[mp2] = mp1 else: print('"side" is not acceptable. See usage') sys.exit(2) ns = NinfoSet() file_ninfo = NinfoFile(sys.argv[1]) file_ninfo.open_to_read() file_ninfo.read_all(ns) file_ninfo.close() ns_new = NinfoSet() # 両方のユニットともターゲットのときは、 # 両方のIDがalnに含まれていないとaddしない # BondLengths add1 = False add2 = False for ni in ns.bondlengths: if ni.iunit1 == target:
#!/usr/bin/env python import sys from cafysis.file_io.ninfo import NinfoFile from cafysis.elements.ninfo import NinfoSet if len(sys.argv) != 3: print("Usage: SCRIPT [input ninfo 1] [input ninfo 2]") sys.exit(2) nf = NinfoFile(sys.argv[1]) nf.open_to_read() ns1 = NinfoSet() nf.read_all(ns1) nf.close() nf = NinfoFile(sys.argv[2]) nf.open_to_read() ns2 = NinfoSet() nf.read_all(ns2) nf.close() nhb1 = len(ns1.hbondDTs) nhb2 = len(ns2.hbondDTs) # Do not use index 0 flag1 = [False] * (nhb1 + 1) flag2 = [False] * (nhb2 + 1)
else: # end5 = 'S' if args.end3 == 'P': nmp = 3 * len(seq[iseq]) - 3 elif args.end3 == 'S': nmp = 3 * len(seq[iseq]) - 2 elif args.end3 == 'B': nmp = 3 * len(seq[iseq]) - 1 nmp_chains.append(nmp) nmp_offset.append(sum(nmp_offset) + nmp) ################################################ ## This is the main object to be constructed ## ################################################ ns = NinfoSet() ############## ## Bond ## ############## nmp_pre = 0 for iseq in range(n_seq): iunit = iseq + 1 n_nt = len(seq[iseq]) # for the first nt if args.end5 == 'P': # P - S bl = BondLength(iunit1=iunit,
import sys from cafysis.file_io.ninfo import NinfoFile from cafysis.elements.ninfo import NinfoSet if __name__ == '__main__': if len(sys.argv) != 10: print( 'Usage: SCRIPT [ninfo (one-by-one)] [unit] [dist] [side] [unit] [dist] [side] [edc (post_edc.out)] [out]' ) print('') sys.exit(2) fninfo_in = NinfoFile(sys.argv[1]) fninfo_in.open_to_read() ns = NinfoSet() fninfo_in.read_all(ns) ns.update_info() fninfo_in.close() fninfo_out = NinfoFile(sys.argv[-1]) fninfo_out.open_to_write() unit_aln1 = int(sys.argv[2]) aln1 = {} side = int(sys.argv[4]) for line in open(sys.argv[3]): linesp = line.split() res1 = int(linesp[0]) # Dunkle res mp1 = int(linesp[1]) # Dunkle mp res2 = int(linesp[2]) # Jenner res
from cafysis.elements.ninfo import NinfoSet if len(sys.argv) != 6: print( 'Usage: SCRIPT [ninfo file] [edc file] [dist(aln) file] [factor] [output ninfo file]' ) sys.exit(2) f_ninfo = NinfoFile(sys.argv[1]) f_edc = open(sys.argv[2], 'r') f_dist = open(sys.argv[3], 'r') factor = float(sys.argv[4]) f_out_ninfo = NinfoFile(sys.argv[-1]) f_ninfo.open_to_read() ninfo = NinfoSet() f_ninfo.read_all(ninfo) f_ninfo.close() f_out_ninfo.open_to_write() f_out_ninfo._file.write('#0: ' + sys.argv[0] + '\n') f_out_ninfo._file.write('#1: ' + sys.argv[1] + '\n') f_out_ninfo._file.write('#2: ' + sys.argv[2] + '\n') f_out_ninfo._file.write('#3: ' + sys.argv[3] + '\n') f_out_ninfo._file.write('#4: ' + sys.argv[4] + '\n') f_out_ninfo._file.write('#5: ' + sys.argv[5] + '\n') aln = {} # Read from dist file ''' # Jenner Dunkle
Created on 2012/01/19 @author: Naoto Hori ''' import sys from cafysis.file_io.ninfo import NinfoFile from cafysis.elements.ninfo import NinfoSet if __name__ == '__main__': if len(sys.argv) != 3: print('Usage: %SCRIPT [input ninfo file] [output prefix]') sys.exit(2) file_ninfo = NinfoFile(sys.argv[1]) file_ninfo.open_to_read() ns = NinfoSet() file_ninfo.read_all(ns) ns.update_info() file_ninfo.close() prefix = sys.argv[2] ndi = ns.dict_of_ninfoset_by_unit() for i in range(1, ns.max_unit + 1): for j in range(i, ns.max_unit + 1): if ndi[(i, j)].max_unit != 0: file_out = NinfoFile(prefix + '%03i_%03i.ninfo' % (i, j)) file_out.open_to_write() file_out.write_all(ndi[(i, j)]) #file_out.write_unit(ns, i, j) file_out.close()
if not len(sys.argv) in (3, 4): print('\nUsage 1: % SCRIPT [ninfo file] [output file (csv)]') print( ' 2: % SCRIPT [ninfo file] [output file (csv)] [output list file]\n' ) sys.exit(2) # input f_ninfo = NinfoFile(sys.argv[1]) f_out = open(sys.argv[2], 'w') flg_out_list = False if len(sys.argv) == 4: flg_out_list = True f_out_list = open(sys.argv[3], 'w') ninfo = NinfoSet() f_ninfo.open_to_read() f_ninfo.read_all(ninfo) f_ninfo.close() ninfo.update_info() nunit = ninfo.max_unit # Count the number of contacts or basepairs data = {} for i in range(1, nunit + 1): for j in range(i, nunit + 1): n_con = len(ninfo.get_contacts_by_unit(i, j)) n_bp = len(ninfo.get_basepairs_by_unit(i, j)) data[(i, j)] = (n_con, n_bp) data[(j, i)] = (n_con, n_bp)