Exemplo n.º 1
0
def pbassign_cli():
    """
    PBassign command line.
    """
    options, pdb_name_lst = user_inputs()

    if options.p:
        if pdb_name_lst:
            print("{} PDB file(s) to process".format(len(pdb_name_lst)))
        else:
            print('Nothing to do. Good bye.')
            return
        # PB assignement of PDB structures
        chains = PDB.chains_from_files(pdb_name_lst)
    else:
        # PB assignement of a Gromacs trajectory
        chains = PDB.chains_from_trajectory(options.x, options.g)

    all_comments = []
    all_sequences = []
    all_dihedrals = []
    for comment, chain in chains:
        dihedrals = chain.get_phi_psi_angles()
        sequence = PB.assign(dihedrals)
        all_comments.append(comment)
        all_dihedrals.append(dihedrals)
        all_sequences.append(sequence)

    fasta_name = options.o + ".PB.fasta"
    with open(fasta_name, 'w') as outfile:
        PB.write_fasta(outfile, all_sequences, all_comments)
    if options.flat:
        flat_name = options.o + ".PB.flat"
        with open(flat_name, 'w') as outfile:
            PB.write_flat(outfile, all_sequences)
    if options.phipsi:
        phipsi_name = options.o + ".PB.phipsi"
        with open(phipsi_name, 'w') as outfile:
            PB.write_phipsi(outfile, all_dihedrals, all_comments)

    print("wrote {0}".format(fasta_name))
    if options.flat:
        print("wrote {0}".format(flat_name))
    if options.phipsi:
        print("wrote {0}".format(phipsi_name))
Exemplo n.º 2
0
def pbassign_cli():
    """
    PBassign command line.
    """
    options, pdb_name_lst = user_inputs()

    if options.p:
        if pdb_name_lst:
            print("{} PDB file(s) to process".format(len(pdb_name_lst)))
        else:
            print('Nothing to do. Good bye.')
            return
        # PB assignement of PDB structures
        chains = PDB.chains_from_files(pdb_name_lst)
    else:
        # PB assignement of a Gromacs trajectory
        chains = PDB.chains_from_trajectory(options.x, options.g)

    all_comments = []
    all_sequences = []
    all_dihedrals = []
    for comment, chain in chains:
        dihedrals = chain.get_phi_psi_angles()
        sequence = PB.assign(dihedrals)
        all_comments.append(comment)
        all_dihedrals.append(dihedrals)
        all_sequences.append(sequence)

    fasta_name = options.o + ".PB.fasta"
    with open(fasta_name, 'w') as outfile:
        PB.write_fasta(outfile, all_sequences, all_comments)
    if options.flat:
        flat_name = options.o + ".PB.flat"
        with open(flat_name, 'w') as outfile:
            PB.write_flat(outfile, all_sequences)
    if options.phipsi:
        phipsi_name = options.o + ".PB.phipsi"
        with open(phipsi_name, 'w') as outfile:
            PB.write_phipsi(outfile, all_dihedrals, all_comments)

    print("wrote {0}".format(fasta_name))
    if options.flat:
        print("wrote {0}".format(flat_name))
    if options.phipsi:
        print("wrote {0}".format(phipsi_name))
Exemplo n.º 3
0
    def test_get_dihedral(self):
        """
        Test for get_dihedral()
        """
        Result = collections.namedtuple("Result", ["A", "B", "C", "D", "torsion"])
        results = (
            Result(
                (-7.28, -9.262, 5.077),
                (-7.526, -10.643, 5.529),
                (-6.221, -11.438, 5.555),
                (-6.289, -12.685, 5.931),
                -179.663656153,
            ),
            Result(
                (-1.373, -8.817, -4.389),
                (-1.203, -8.335, -5.792),
                (-1.891, -6.977, -5.927),
                (-1.918, -6.429, -7.107),
                -176.048770127,
            ),
            Result(
                (-0.533, -8.42, -3.47),
                (-1.373, -8.817, -4.389),
                (-1.203, -8.335, -5.792),
                (-1.891, -6.977, -5.927),
                -84.8356057692,
            ),
            Result(
                (-1.918, -6.429, -7.107),
                (-2.609, -5.125, -7.305),
                (-4.108, -5.392, -7.331),
                (-4.469, -6.494, -7.911),
                -36.8942888266,
            ),
            Result(
                (-11.285, 6.472, -7.44),
                (-12.62, 5.829, -7.425),
                (-13.585, 6.626, -6.544),
                (-13.098, 7.621, -5.858),
                -6.58786169376,
            ),
            Result(
                (-11.284, -0.971, -2.679),
                (-12.65, -0.794, -3.226),
                (-13.665, -1.664, -2.479),
                (-13.262, -2.363, -1.452),
                3.91626706556,
            ),
            Result(
                (-2.004, -10.892, -2.611),
                (-1.87, -9.835, -1.853),
                (-0.726, -8.877, -2.011),
                (-0.533, -8.42, -3.47),
                50.065196067,
            ),
            Result(
                (11.174, -6.725, 0.458),
                (10.732, -7.258, -0.86),
                (9.27, -6.869, -1.096),
                (8.741, -7.185, -2.245),
                175.872397707,
            ),
        )

        for res in results:
            torsion = PDB.get_dihedral(res.A, res.B, res.C, res.D)
            self.assertAlmostEqual(torsion, res.torsion)