view @ 3:ad135cf42274 draft

planemo upload for repository commit 3ff06e3182c3a1546ea0a3b29e0d4383e12169e1
author chemteam
date Wed, 03 Apr 2019 15:47:56 -0400
children e7d0075052c9
line wrap: on
line source

#!/usr/bin/env python

import argparse
import csv
import sys

import MDAnalysis as mda
import MDAnalysis.analysis.pca as pca

import numpy as np

def parse_command_line(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument('--idcd', help='input dcd')
    parser.add_argument('--ipdb', help='input pdb')
    parser.add_argument('--icomponents', help='number of principle components')
    parser.add_argument('--iindex', help='index of the PC')
    parser.add_argument('--output', help='output')
    parser.add_argument('--cosout', help='cosine output')
    return parser.parse_args()

args = parse_command_line(sys.argv)

u = mda.Universe(args.ipdb, args.idcd, topology_format="PDB", format="DCD")

components = int(args.icomponents)
pca_index = int(args.iindex)

PSF_pca = pca.PCA(u, select='backbone')
n_pcs = np.where(PSF_pca.cumulated_variance > 0.95)[0][0]
atomgroup = u.select_atoms('backbone')

pca_space = PSF_pca.transform(atomgroup, n_components=components)
cosine = mda.analysis.pca.cosine_content(pca_space, pca_index)

PCA = list(pca_space)

with open(args.output, 'w') as f:
    writer = csv.writer(f, delimiter='\t')

with open(args.cosout, 'w') as f1: