⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmff94basedparametersetreader.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				data.add(new Double(va4));			}			parameterSet.put(key, data);		} catch (NumberFormatException nfe) {			throw new IOException("setAngle: Malformed Number due to:"+nfe);		}	}			/**	 *  Sets the strBnd attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setStrBnd() throws Exception {		Vector data = new Vector();		st.nextToken();		String scode = st.nextToken(); // String scode		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String sid3 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();				try {		    //int code=new Integer(scode).intValue();			double va1 = new Double(value1).doubleValue();			double va2 = new Double(value2).doubleValue();			data.add(new Double(va1));			data.add(new Double(va2));					} catch (NumberFormatException nfe) {			throw new IOException("setStrBnd: Malformed Number due to:"+nfe);		}		key = "strbnd" + scode + ";" + sid1 + ";" + sid2 + ";" + sid3;		//logger.debug("key =" + key);		parameterSet.put(key, data);	}		/**	 *  Sets the torsion attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setTorsion() throws Exception {		Vector data = null;		st.nextToken();		String scode = st.nextToken(); // String scode		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String sid3 = st.nextToken();		String sid4 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();		String value3 = st.nextToken();		String value4 = st.nextToken();		String value5 = st.nextToken();				try {			double va1 = new Double(value1).doubleValue();			double va2 = new Double(value2).doubleValue();			double va3 = new Double(value3).doubleValue();			double va4 = new Double(value4).doubleValue();			double va5 = new Double(value5).doubleValue();			key = "torsion" + scode + ";" + sid1 + ";" + sid2 + ";" + sid3 + ";" + sid4;			//logger.debug("key = " + key);			if (parameterSet.containsKey(key)) {				data = (Vector) parameterSet.get(key);				data.add(new Double(va1));				data.add(new Double(va2));				data.add(new Double(va3));				data.add(new Double(va4));				data.add(new Double(va5));				//logger.debug("data = " + data);			}			else{			    data = new Vector();			    data.add(new Double(va1));			    data.add(new Double(va2));			    data.add(new Double(va3));			    data.add(new Double(va4));			    data.add(new Double(va5));				//logger.debug("data = " + data);			}			parameterSet.put(key, data);		} catch (NumberFormatException nfe) {			throw new IOException("setTorsion: Malformed Number due to:"+nfe);		}	}		/**	 *  Sets the opBend attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setOpBend() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String sid3 = st.nextToken();		String sid4 = st.nextToken();		String value1 = st.nextToken();		try {			double va1 = new Double(value1).doubleValue();			data.add(new Double(va1));			key = "opbend" + sid1 + ";" + sid2 + ";" + sid3 + ";" + sid4;			if (parameterSet.containsKey(key)) {				data = (Vector) parameterSet.get(key);				data.add(new Double(va1));			}			parameterSet.put(key, data);		} catch (NumberFormatException nfe) {			throw new IOException("setOpBend: Malformed Number due to:"+nfe);		}	}			/**	 *  Sets the Default Stretch-Bend Parameters into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setDefaultStrBnd() throws Exception {		//logger.debug("Sets the Default Stretch-Bend Parameters");		Vector data = new Vector();		stDFSB.nextToken();		String sIR = stDFSB.nextToken();		String sJR = stDFSB.nextToken();		String sKR = stDFSB.nextToken();		String skbaIJK = stDFSB.nextToken();		String skbaKJI = stDFSB.nextToken();		try {			key = "DFSB" + sIR + ";" + sJR + ";" + sKR;			double kbaIJK = new Double(skbaIJK).doubleValue();			double kbaKJI = new Double(skbaKJI).doubleValue();			data.add(new Double(kbaIJK));			data.add(new Double(kbaKJI));			parameterSet.put(key, data);		} catch (NumberFormatException nfe) {			throw new IOException("setDFSB: Malformed Number due to:"+nfe);		}	}			/**	 * The main method which parses through the force field configuration file	 *	 * @exception  Exception  Description of the Exception	 */	public void readParameterSets() throws Exception {		//vdW,bond,angle,strbond,opbend,torsion,data		//logger.debug("------ Read MMFF94 ParameterSets ------");		if (ins == null) {            ClassLoader loader = this.getClass().getClassLoader();            System.out.println("loader.getClassName:" + loader.getClass().getName());			ins = loader.getResourceAsStream(configFile);		}		if (ins == null) {			throw new IOException("There was a problem getting the default stream: " + configFile);		}				BufferedReader r = new BufferedReader(new InputStreamReader(ins), 1024);		String s;		int[] a = {0, 0, 0, 0, 0, 0, 0, 0};				if (insvdW == null) {			insvdW = this.getClass().getClassLoader().getResourceAsStream(configFilevdW);		}		if (insvdW == null) {			throw new IOException("There was a problem getting the default stream: " + configFilevdW);		}				BufferedReader rvdW = new BufferedReader(new InputStreamReader(insvdW), 1024);		String svdW;		int ntvdW;						if (insDFSB == null) {			insDFSB = this.getClass().getClassLoader().getResourceAsStream(configFileDFSB);		}		if (insDFSB == null) {			throw new IOException("There was a problem getting the default stream: " + configFileDFSB);		}				BufferedReader rDFSB = new BufferedReader(new InputStreamReader(insDFSB), 1024);		String sDFSB;		int ntDFSB;						try {			while (true) {				s = r.readLine();				if (s == null) {					break;				}				st = new StringTokenizer(s,"\t; ");				int nt = st.countTokens();				if (s.startsWith("atom") & nt <= 8) {					setAtomTypes();					a[0]++;				} else if (s.startsWith("bond") & nt == 9) {					setBond();					a[1]++;				} else if (s.startsWith("angle") & nt <= 10) {					setAngle();					a[2]++;				} else if (s.startsWith("strbnd") & nt == 7) {					setStrBnd();					a[3]++;				} else if (s.startsWith("torsion") & nt == 11) {					setTorsion();					a[4]++;									} else if (s.startsWith("opbend") & nt == 6) {					setOpBend();					a[5]++;				} else if (s.startsWith("data") & nt == 10) {					readatmmffvdw:						while (true) {							svdW = rvdW.readLine();							if (svdW == null) {								break;							}							stvdW = new StringTokenizer(svdW,"\t; ");							ntvdW = stvdW.countTokens();							//logger.debug("ntvdW : " + ntvdW);							if (svdW.startsWith("vdw") & ntvdW == 9) {								st.nextToken();								sid = st.nextToken();								stvdW.nextToken();								sidvdW = stvdW.nextToken();								if (sid.equals(sidvdW)) {									setAtomTypeData();									a[6]++;								}								break readatmmffvdw;							}						}// end while				}			}// end while			ins.close();			insvdW.close();		} catch (IOException e) {			System.err.println(e.toString());			throw new IOException("There was a problem parsing the mmff94 forcefield");		}		try {			//logger.debug("Parses the Default Stretch-Bend Parameters");			while (true) {				sDFSB = rDFSB.readLine();				//logger.debug("sDFSB = " + sDFSB);				if (sDFSB == null) {					//logger.debug("sDFSB == null, break");					break;				}				stDFSB = new StringTokenizer(sDFSB,"\t; ");				ntDFSB = stDFSB.countTokens();				//logger.debug("ntDFSB : " + ntDFSB);				if (sDFSB.startsWith("DFSB") & ntDFSB == 6) {					setDefaultStrBnd();				}			}			insDFSB.close();			//logger.debug("insDFSB closed");		} catch (IOException e) {			System.err.println(e.toString());			throw new IOException("There was a problem parsing the Default Stretch-Bend Parameters (mmffdfsb.par)");		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -