- Windows
- Python (3.9)
-
import os
import glob
import search_atom
import matplotlib.pyplot as plt -
Python:
[*]import os import glob import search_atom import matplotlib.pyplot as plt x = [] y = [] pattern = "*.extout" path = 'D:/universe/python_deoxycydtidline1/deoxycydtidine1' plt.figure() for filename in glob.glob(os.path.join(path, pattern)): f = open(filename).read() search_atom.search(f) for i in search_atom.atom.V: y.append(float(i) * 0.5) search_atom.atom.V = [] x = [] n = len(y) - len(x) if n == 0: continue else: for i in range(n): x.append(filename.split('_')[-1].strip('.extout')) sort_by_name = {} def create_func(): m = [] for i in range(len(search_atom.atom.name) - 1): if sort_by_name.get(search_atom.atom.name[i]) == None: sort_by_name[search_atom.atom.name[i]] = [] m.append(y) sort_by_name[search_atom.atom.name[i]] = m[0] m = [] create_func() for i,k in sort_by_name.items(): print(i,'+',k) [*]
-
Python:
import re class atom: name = [] V = [] def search(f): searching = re.split(r'Electron Density Critical Point Analysis of Molecular Structure', f) CP = re.split(r'CP#', str(searching[1])) CP_index = 1 while CP_index <= len(CP) - 1: temp = re.search(r'Type = \(3,-1\) BCP H\d[\d,\s]? [N,O]\d[\d,\s]?', str(CP[CP_index])) temp1 = re.search(r'Type = \(3,-1\) BCP [N,O]\d[\d,\s]? H\d[\d,\s]?', str(CP[CP_index])) if temp != None or temp1 != None: DelSqRho = re.search(r'DelSqRho = \s?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+\-]?\d+)?', str(CP[CP_index])) if DelSqRho != None: if temp != None: atom.name.append(temp[0].split('BCP')[1].strip()) elif temp1 != None: atom.name.append(temp1[0].split('BCP')[1].strip()) temp_V = re.search(r'V = [ \-]?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+\-]?\d+)?', str(CP[CP_index])) atom.V.append(temp_V[0].split()[2]) CP_index += 1
график это каждый search_atom.atom.name
где по оси х будет значение угла(filename.split('_')[-1].strip('.extout')), а по оси у будет значение V*0.5(search_atom.atom.V)