-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgetSize.py
executable file
·72 lines (64 loc) · 1.94 KB
/
getSize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
import os
import sys
import random
import time
from random import seed, randint
import argparse
import platform
from datetime import datetime
import imp
import numpy as np
import fileinput
from itertools import product
import pandas as pd
from scipy.interpolate import griddata
from scipy.interpolate import interp2d
import seaborn as sns
from os import listdir
import matplotlib.pyplot as plt
import seaborn as sns
from scipy.interpolate import griddata
import matplotlib as mpl
# sys.path.insert(0,'..')
# from notebookFunctions import *
# from .. import notebookFunctions
from Bio.PDB.PDBParser import PDBParser
from pyCodeLib import *
parser = argparse.ArgumentParser(
description="This is a python3 script to\
automatic copy the template file, \
run simulation and analysis")
parser.add_argument("file", help="The name of the pdb or fasta file")
parser.add_argument("-v", "--verbose", action="store_true", default=False)
# parser.add_argument("-l", "--label", type=str, default="/Users/weilu/opt/ff_contact/1r69/")
# parser.add_argument("-f", "--familyFold", action="store_true", default=False)
args = parser.parse_args()
if args.file[-4:] == ".pdb":
parser = PDBParser(PERMISSIVE=1,QUIET=True)
structure = parser.get_structure("X", args.file)
count = 0
for res in structure.get_residues():
if res.get_id()[0] != " ":
continue # skip
try:
res["CA"].get_vector()
except:
print(structure, res.get_full_id())
continue
count += 1
if args.verbose:
print(count, res.get_full_id()[2], res.get_id()[1], res.get_id()[1]-count)
size = count
print(args.file, size)
# print("-----")
if args.file[-6:] == ".fasta":
seq = ""
with open(args.file) as f:
for line in f:
if line[0] == ">":
continue
seq += line.strip()
# seq
n=len(seq)
print(args.file, n)