/// <summary> /// 公有构造函数 /// </summary> /// <param name="type">氨基酸类型</param> /// <param name="isStandard">是否是标准残基</param> /// <param name="atoms">构成氨基酸得原子</param> /// <param name="connection">原子间的连接关系</param> internal Aminoacid(AminoacidType type, string chinese, bool isStandard, IList <string> atomNames, IDictionary <KeyValuePair <string, string>, BondType> connection) { this.Type = type; this.Chinese = chinese; List <AtomInAminoacid> atoms = new List <AtomInAminoacid>(); foreach (string name in atomNames) { AtomInAminoacid atomInAminoacid = new AtomInAminoacid(name) { Aminoacid = this, }; atoms.Add(atomInAminoacid); } //Atoms = new ReadOnlyCollection<AtomInAminoacid>(atoms); atomDic = new Dictionary <string, AtomInAminoacid>(); foreach (var child in atoms) { atomDic.Add(child.Name, child); } Dictionary <KeyValuePair <AtomInAminoacid, AtomInAminoacid>, BondType> connectDic = new Dictionary <KeyValuePair <AtomInAminoacid, AtomInAminoacid>, BondType>(); foreach (var child in connection) { // this是38行的索引器的调用,即输入原子名字string(含后缀的),返回对应的原子实例 connectDic.Add(new KeyValuePair <AtomInAminoacid, AtomInAminoacid>(this[child.Key.Key], this[child.Key.Value]), child.Value); } Connections = new ReadOnlyDictionary <KeyValuePair <AtomInAminoacid, AtomInAminoacid>, BondType>(connectDic); }
public override bool Equals(object obj) { AtomInAminoacid atom = obj as AtomInAminoacid; if (atom == null) { return(false); } else { return(this.Aminoacid == atom.Aminoacid && this.Name == atom.Name); } }