Esempio n. 1
0
            pass
        else:
            ns_new.basepairs.append(ni)
        add1 = False
        add2 = False

    # BaseStacks
    add1 = False
    add2 = False
    for ni in ns.basestacks:
        if ni.iunit1 == target:
            if ni.imp1un in aln:
                ni.imp1un = aln[ni.imp1un]
                add1 = True
        if ni.iunit2 == target:
            if ni.imp2un in aln:
                ni.imp2un = aln[ni.imp2un]
                add2 = True
        if ((ni.iunit1 == target and not add1)
                or (ni.iunit2 == target and not add2)):
            pass
        else:
            ns_new.basestacks.append(ni)
        add1 = False
        add2 = False

    out_ninfo = NinfoFile(sys.argv[5])
    out_ninfo.open_to_write()
    out_ninfo.write_all(ns_new)
    out_ninfo.close()
Esempio n. 2
0
#!/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()
Esempio n. 3
0
        if unit_aln1 == iunit1 and unit_aln2 == iunit2:
            aln_mp1_u = aln1[con.imp1un]
            aln_mp2_u = aln2[con.imp2un]
        elif unit_aln1 == iunit2 and unit_aln2 == iunit2:
            aln_mp1_u = aln2[con.imp1un]
            aln_mp2_u = aln1[con.imp2un]
        else:
            print('Error:')
            print('unit_aln1:', unit_aln1)
            print('unit_aln2:', unit_aln2)
            print('con.iunit1:', iunit1)
            print('con.iunit2:', iunit2)
            sys.exit(2)

        if (aln_mp1_u, aln_mp2_u) in pairlist:
            energy = pairlist[(aln_mp1_u, aln_mp2_u)].energy
        elif (aln_mp2_u, aln_mp1_u) in pairlist:
            energy = pairlist[(aln_mp2_u, aln_mp1_u)].energy
        else:
            energy = 0.0
            print('caution: pair is not found.')
            print('icon=', con.id)

        if energy < 0.0:
            con.factor = -1.0 * energy
        else:
            con.factor = 0.0

    fninfo_out.write_all(ns)
    fninfo_out.close()
Esempio n. 4
0
            dih2_imp1un=imp_1_un,
            dih2_imp2un=imp_2_un,
            dih2_imp3un=imp_4_un,
            dih2_imp4un=imp_6_un,
            dih2_native=dih2_native,
            dih2_coef=CHT18.HB_DIH_CHAIN,
        )

        ns.hbondDTs.append(hb)

    ###########################
    ## Generate ninfo file   ##
    ###########################
    nf = NinfoFile(args.outfile)
    nf.open_to_write()
    nf.write_all(ns)
    nf.close()

    ###################################
    ## Generate exv file (optional)  ##
    ###################################
    if args.exvfile:
        n_sep_nlocal_P = 3
        n_sep_nlocal_S = 3
        n_sep_nlocal_B = 2

        if args.end5 == 'P':
            nmp = 3 * n_nt
        else:
            nmp = 3 * n_nt - 1
Esempio n. 5
0
for bd in ninfo.bondlengths:
    ninfo_out[(bd.iunit1, bd.iunit2)].bondlengths.append(bd)

for ba in ninfo.bondangles:
    ninfo_out[(ba.iunit1, ba.iunit2)].bondangles.append(ba)

for dih in ninfo.dihedrals:
    ninfo_out[(dih.iunit1, dih.iunit2)].dihedrals.append(dih)

for con in ninfo.contacts:
    ninfo_out[(con.iunit1, con.iunit2)].contacts.append(con)

for bp in ninfo.basepairs:
    ninfo_out[(bp.iunit1, bp.iunit2)].basepairs.append(bp)

for bs in ninfo.basestacks:
    ninfo_out[(bs.iunit1, bs.iunit2)].basestacks.append(bs)

for i in range(1, nUnit + 1):
    for j in range(i, nUnit + 1):
        if (len(ninfo_out[(i, j)].bondlengths) != 0
                or len(ninfo_out[(i, j)].bondangles) != 0
                or len(ninfo_out[(i, j)].dihedrals) != 0
                or len(ninfo_out[(i, j)].contacts) != 0
                or len(ninfo_out[(i, j)].basepairs) != 0
                or len(ninfo_out[(i, j)].basestacks) != 0):
            filename = out_prefix + '%i_%i' % (i, j) + '.ninfo'
            nf = NinfoFile(filename)
            nf.open_to_write()
            nf.write_all(ninfo_out[(i, j)])
Esempio n. 6
0
#        f_out.write('%3i %6i %4s %6i %3s | %3i %6i %4s %6i %3s | %6i %6i | %f\n' % info)
    linesp = line.split()
    imp1_orig = int(linesp[3])
    imp2_orig = int(linesp[9])
    if imp1_orig in aln:
        imp1_tp = aln[imp1_orig]
    else:
        continue
    if imp2_orig in aln:
        imp2_tp = aln[imp2_orig]
    else:
        continue
    for imp1 in imp1_tp:
        for imp2 in imp2_tp:
            if (imp1, imp2) in energys:
                print(('Error: (imp1,imp2) in energys = True', imp1_orig,
                       imp2_orig, imp1, imp2))
            energys[(imp1, imp2)] = float(linesp[15])
f_edc.close()

for con in ninfo.contacts:
    if (con.imp1, con.imp2) in energys:
        e = energys[(con.imp1, con.imp2)]
        if e > 0.0:
            con.coef = 0.0
        else:
            con.coef = factor * (-1.0 * e) * con.coef

f_out_ninfo.write_all(ninfo)
f_out_ninfo.close()
Esempio n. 7
0
            imp2_offset += c2.num_res()
            
        imp1_offset += c1.num_res()
    return


if __name__ == '__main__':
    import sys
    if len(sys.argv) != 3:
        print ('Usage: %SCRIPT [input PDB] [output ninfo]')
        sys.exit(2)

    from cafysis.file_io.pdb import PdbFile
    from cafysis.file_io.ninfo import NinfoFile
    from cafysis.elements.ninfo import NinfoSet

    f = PdbFile(sys.argv[1])
    f.open_to_read()
    chains = f.read_all()
    f.close()

    ns = NinfoSet()
    generate_FENEs(chains, ns)
    generate_LJs(chains, ns)

    f_ninfo = NinfoFile(sys.argv[-1])
    f_ninfo.open_to_write()
    f_ninfo.write_all(ns)
    f_ninfo.close()

#!/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] [factor] [output ninfo]")
    sys.exit(2)

f_ninfo_in = NinfoFile(sys.argv[1])
f_ninfo_in.open_to_read()
ninfo = NinfoSet()
f_ninfo_in.read_all(ninfo)
f_ninfo_in.close()

k_factor = float(sys.argv[2])

f_ninfo_out = NinfoFile(sys.argv[-1])
f_ninfo_out.open_to_write()

for con in ninfo.contacts:
    con.coef = con.coef * k_factor * con.factor
    con.factor = 1.0

f_ninfo_out.write_all(ninfo)
f_ninfo_out.close()
Esempio n. 9
0
@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()