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

📄 mm2basedparametersetreader.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			double va4 = new Double(value4).doubleValue();			data.add(new Double(va1));			data.add(new Double(va2));			data.add(new Double(va3));			data.add(new Double(va4));			key = "angle" + sid1 + ";" + sid2 + ";" + sid3;			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));			}			parameterSet.put(key, data);		} catch (NumberFormatException nfe) {			throw new IOException("setAngle: Malformed Number");		}	}	/**	 *  Sets the angle3 attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setAngle3() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String sid3 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();		String value3 = st.nextToken();		String value4 = 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();			data.add(new Double(va1));			data.add(new Double(va2));			data.add(new Double(va3));			data.add(new Double(va4));		} catch (NumberFormatException nfe) {			throw new IOException("setAngle3: Malformed Number");		}		key = "angle3_" + sid1 + ";" + sid2 + ";" + sid3;		parameterSet.put(key, data);	}	/**	 *  Sets the angle4 attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setAngle4() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String sid3 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();		String value3 = st.nextToken();		String value4 = 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();			data.add(new Double(va1));			data.add(new Double(va2));			data.add(new Double(va3));			data.add(new Double(va4));		} catch (NumberFormatException nfe) {			throw new IOException("setAngle4: Malformed Number");		}		key = "angle4_" + sid1 + ";" + sid2 + ";" + sid3;		parameterSet.put(key, data);	}	/**	 *  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 sid1 = st.nextToken();		String value1 = st.nextToken();		try {			double va1 = new Double(value1).doubleValue();			data.add(new Double(va1));		} catch (NumberFormatException nfe) {			throw new IOException("setStrBnd: Malformed Number");		}		key = "strbnd" + sid1;		parameterSet.put(key, data);	}	/**	 *  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 value1 = st.nextToken();		try {			double va1 = new Double(value1).doubleValue();			data.add(new Double(va1));			key = "opbend" + sid1 + ";" + sid2;			if (parameterSet.containsKey(key)) {				//logger.debug("KeyError: hasKey "+key);				data = (Vector) parameterSet.get(key);				data.add(new Double(va1));			}			parameterSet.put(key, data);		} catch (NumberFormatException nfe) {			throw new IOException("setOpBend: Malformed Number");		}	}	/**	 *  Sets the torsion attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setTorsion() 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();		st.nextToken();		st.nextToken();		String value2 = st.nextToken();		st.nextToken();		st.nextToken();		String value3 = st.nextToken();		st.nextToken();		st.nextToken();		try {			double va1 = new Double(value1).doubleValue();			double va2 = new Double(value2).doubleValue();			double va3 = new Double(value3).doubleValue();			data.add(new Double(va1));			data.add(new Double(va2));			data.add(new Double(va3));			key = "torsion" + sid1 + ";" + sid2 + ";" + sid3 + ";" + sid4;			if (parameterSet.containsKey(key)) {				data = (Vector) parameterSet.get(key);				data.add(new Double(va1));				data.add(new Double(va2));				data.add(new Double(va3));			}			parameterSet.put(key, data);		} catch (NumberFormatException nfe) {			throw new IOException("setTorsion: Malformed Number");		}	}	/**	 *  Sets the torsion4 attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setTorsion4() 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();		st.nextToken();		st.nextToken();		String value2 = st.nextToken();		st.nextToken();		st.nextToken();		String value3 = st.nextToken();		st.nextToken();		st.nextToken();		try {			double va1 = new Double(value1).doubleValue();			double va2 = new Double(value2).doubleValue();			double va3 = new Double(value3).doubleValue();			data.add(new Double(va1));			data.add(new Double(va2));			data.add(new Double(va3));		} catch (NumberFormatException nfe) {			throw new IOException("setTorsion4: Malformed Number");		}		key = "torsion4_" + sid1 + ";" + sid2 + ";" + sid3 + ";" + sid4;		parameterSet.put(key, data);	}	/**	 *  Sets the charge attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setCharge() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String value1 = st.nextToken();		try {			double va1 = new Double(value1).doubleValue();			data.add(new Double(va1));		} catch (NumberFormatException nfe) {			throw new IOException("setCharge: Malformed Number due to "+nfe.toString());		}		key = "charge" + sid1;		parameterSet.put(key, data);	}	/**	 *  Sets the dipole attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setDipole() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();		try {			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("setDipole: " +					"Malformed Number");		}		key = "dipole" + sid1 + ";" + sid2;		parameterSet.put(key, data);	}	/**	 *  Sets the dipole3 attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setDipole3() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();		try {			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("setDipole3: " +					"Malformed Number");		}		key = "dipole3_" + sid1 + ";" + sid2;		parameterSet.put(key, data);	}	/**	 *  Sets the piAtom attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setPiAtom() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();		String value3 = st.nextToken();		try {			double va1 = new Double(value1).doubleValue();			double va2 = new Double(value2).doubleValue();			double va3 = new Double(value3).doubleValue();			data.add(new Double(va1));			data.add(new Double(va2));			data.add(new Double(va3));		} catch (NumberFormatException nfe) {			throw new IOException("setPiAtom: " +					"Malformed Number");		}		key = "piatom" + sid1;		parameterSet.put(key, data);	}	/**	 *  Sets the piBond attribute stored into the parameter set	 *	 * @exception  Exception  Description of the Exception	 */	private void setPiBond() throws Exception {		Vector data = new Vector();		st.nextToken();		String sid1 = st.nextToken();		String sid2 = st.nextToken();		String value1 = st.nextToken();		String value2 = st.nextToken();		try {			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("setPiBond: " +					"Malformed Number");		}		key = "pibond" + sid1 + ";" + sid2;		parameterSet.put(key, data);	}	/**	 * The main method which parses through the force field configuration file	 *	 * @exception  Exception  Description of the Exception	 */	public void readParameterSets() throws Exception {		//vdW,vdWp,bond,bond4,bond3,angle,angle4,angle3,		//strbond,opbend,torsion,torsion4,charge,dipole,		//dipole3,piatom,pibond,dipole3		//logger.debug("------ ReadParameterSets ------");		if (ins == null) {			ins = getClass().getResourceAsStream(configFile);		}		if (ins == null) {			throw new IOException("There was a problem getting the default stream: " + configFile);		}		// read the contents from file		BufferedReader r = new BufferedReader(new InputStreamReader(ins), 1024);		String s;		int[] a = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};		try {			while (true) {				s = r.readLine();				if (s == null) {					break;				}				st = new StringTokenizer(s, "\t ;");				int nt = st.countTokens();				if (s.startsWith(">") & nt > 1) {					setForceFieldDefinitions();					a[0]++;				} else if (s.startsWith("atom") & nt <= 8) {					a[0]++;					setAtomTypes();				} else if (s.startsWith("vdw ") & nt <= 5) {					setvdWaals();					a[1]++;				} else if (s.startsWith("vdwpr ") & nt <= 6) {					setvdWaalpr();					a[2]++;				} else if (s.startsWith("bond ") & nt <= 7) {					setBond();					a[3]++;				} else if (s.startsWith("bond4 ") & nt == 5) {					setBond4();					a[4]++;				} else if (s.startsWith("bond3 ") & nt == 5) {					setBond3();					a[5]++;				} else if (s.startsWith("angle ") & nt == 8) {					setAngle();					a[6]++;				} else if (s.startsWith("angle4 ") & nt == 8) {					setAngle4();					a[17]++;				} else if (s.startsWith("angle3 ") & nt == 8) {					setAngle3();					a[7]++;				} else if (s.startsWith("strbnd ") & nt == 5) {					setStrBnd();					a[8]++;				} else if (s.startsWith("opbend ") & nt == 4) {					setOpBend();					a[9]++;				} else if (s.startsWith("torsion ") & nt == 14) {					setTorsion();					a[10]++;				} else if (s.startsWith("torsion4 ") & nt == 14) {					setTorsion4();					a[11]++;				} else if (s.startsWith("charge ") & nt == 3) {					setCharge();					a[12]++;				} else if (s.startsWith("dipole ") & nt == 5) {					setDipole();					a[13]++;				} else if (s.startsWith("dipole3 ") & nt == 5) {					setDipole3();					a[14]++;				} else if (s.startsWith("piatom ") & nt == 5) {					setPiAtom();					a[15]++;				} else if (s.startsWith("pibond ") & nt == 5) {					setPiBond();					a[16]++;				} 			}// end while			ins.close();		} catch (IOException e) {			throw new IOException("There was a problem parsing the mm2 forcefield due to:"+e.toString());		}	}}

⌨️ 快捷键说明

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