Example #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))
Example #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))