/// <summary> /// write a chain into a pdb formatted file /// </summary> /// <param name="chain">atoms</param> /// <param name="chainId">chain id</param> /// <param name="atomId">start atom sequential number for this chain</param> /// <param name="fileWriter">file id to write</param> public void WriteOneChainInAuthNumbering(AtomInfo[] chain, string chainId, ref int atomId, StreamWriter fileWriter) { string line = ""; AtomInfo lastAtom = new AtomInfo(); List <string> addedAtomsList = new List <string>(); string seqAtomName = ""; foreach (AtomInfo atom in chain) { seqAtomName = atom.authSeqId + "_" + atom.authResidue + "_" + atom.atomName; // in case duplicated although not duplicate in coordinates in original PDB file. // we use the atom A here // e.g. 4DAU: // ATOM 309 CA ACYS A 38 24.056 25.197 -5.623 0.70 11.48 C // ATOM 310 CA BCYS A 38 24.032 25.181 -5.606 0.30 13.22 C // modified on March 15, 2013, especially for Pymol pair_fit which needs exactly same atoms aligned. if (addedAtomsList.Contains(seqAtomName)) { continue; } atomId++; if (atomId > maxAtomId) { atomId = 1; } line = FormatAtomLineAuthResidueNumbering(atom, chainId, atomId); fileWriter.WriteLine(line); lastAtom = atom; addedAtomsList.Add(seqAtomName); } atomId++; string lastLine = FormatLastAtomLineInAuthResidueNumbering(lastAtom, chainId, atomId); fileWriter.WriteLine(lastLine); }
/// <summary> /// convert from a list atoms to a list of residues /// </summary> /// <param name="atoms"></param> /// <returns></returns> private Residue[] GetResidues(AtomInfo[] atoms) { Hashtable residueSeqHash = new Hashtable(); foreach (AtomInfo atom in atoms) { if (residueSeqHash.ContainsKey(atom.seqId)) { ArrayList atomList = (ArrayList)residueSeqHash[atom.seqId]; atomList.Add(atom); residueSeqHash[atom.seqId] = atomList; } else { ArrayList atomList = new ArrayList(); atomList.Add(atom); residueSeqHash.Add(atom.seqId, atomList); } } Residue[] residues = new Residue [residueSeqHash.Count]; int count = 0; foreach (string seqId in residueSeqHash.Keys) { AtomInfo[] residueAtoms = new AtomInfo [((ArrayList)residueSeqHash[seqId]).Count]; ((ArrayList)residueSeqHash[seqId]).CopyTo(residueAtoms); residues[count] = new Residue(residueAtoms); count++; } return(residues); }
/// <summary> /// /// </summary> /// <param name="atom"></param> /// <returns></returns> private string FormatAtomLine(string chainId, AtomInfo atom) { string line = "ATOM "; line += atom.atomId.ToString().PadLeft(5, ' '); line += " "; string atomName = atom.atomName; if (atomName != "" && atomName.Length < 4) { atomName = " " + atomName; } line += atomName.PadRight(4, ' '); line += " "; line += atom.residue.PadLeft(3, ' '); line += " "; line += chainId; line += atom.seqId.PadLeft(4, ' '); line += " "; line += FormatDoubleString(atom.xyz.X, 4, 3); line += FormatDoubleString(atom.xyz.Y, 4, 3); line += FormatDoubleString(atom.xyz.Z, 4, 3); line += " 1.00"; line += " 0.00"; line += " "; line += atom.atomType; return(line); }
/// <summary> /// /// </summary> /// <param name="atom"></param> /// <param name="atomId"></param> /// <returns></returns> public string FormatAtomLine(AtomInfo atom, string chainId, int atomId) { string atomLineHeader = "ATOM "; string atomLine = FormatAtomLine(atomLineHeader, atom, chainId, atomId); return(atomLine); }
/// <summary> /// /// </summary> /// <param name="fileName"></param> /// <param name="remarkString"></param> /// <param name="atoms"></param> private void WriteAtomsToFile(string fileName, string fileChain, string remarkString, AtomInfo[] atoms) { StreamWriter dataWriter = new StreamWriter(fileName); dataWriter.WriteLine(remarkString); string atomLine = ""; AtomInfo lastAtom = null; foreach (AtomInfo atom in atoms) { atomLine = FormatAtomLine(fileChain, atom); dataWriter.WriteLine(atomLine); lastAtom = atom; } string line = "TER "; int atomId = lastAtom.atomId + 1; line += atomId.ToString().PadLeft(5, ' '); line += " "; line += lastAtom.residue.PadLeft(3, ' '); line += " "; line += fileChain; line += lastAtom.seqId.PadLeft(4, ' '); dataWriter.WriteLine(line); dataWriter.WriteLine("END"); dataWriter.Close(); }
public void RemoveAtomA() { if (atomA != null && atomChoices.Count > atomA.GetAtomicNumber()) { ChoiceOption choiceOption = atomChoices[atomA.GetAtomicNumber() - 1]; var atom = atomA; choiceOption.SetButtonEvent(() => { SetAtom(atom); AudioManager.Instance.PlaySound(choiceClickSound); }); choiceOption.SetColors(ChoiceOption.defaultNormalColor, ChoiceOption.defaultHoverColor, ChoiceOption.defaultPressedColor); choiceOption.SetFocus(false); } //if (atomA != null) { // atomChoices[atomA.GetAtomicNumber() - 1].SetInteractable(true); //} atomA = null; AtomInfo info = Game.Instance.gameData.GetUknownInfo(); atomAText.text = info.GetAtom().GetName(); atomAImage.sprite = info.GetImage(); splitBtn.interactable = false; infoText.text = ""; atomResultImage.sprite = info.GetImage(); atomResultText.text = info.GetAtom().GetName(); atomAAmoText.text = ""; atomAAmo.value = 0; atomABtn.interactable = false; }
/// <summary> /// /// </summary> /// <param name="coordFile"></param> /// <param name="remarkString"></param> /// <returns></returns> public AtomInfo[] ReadChainCoordFile(string coordFile, out string remarkString) { StreamReader atomReader = new StreamReader(coordFile); List <AtomInfo> atomInfoList = new List <AtomInfo> (); string line = ""; remarkString = ""; while ((line = atomReader.ReadLine()) != null) { if (line.IndexOf("REMARK") > -1) { remarkString += (line + "\r\n"); } if (line.IndexOf("ATOM ") > -1) { string[] fields = ParseHelper.ParsePdbAtomLine(line); AtomInfo atom = new AtomInfo(); atom.atomId = Convert.ToInt32(fields[1]); atom.atomName = fields[2]; atom.residue = fields[4]; atom.seqId = fields[6]; atom.xyz.X = Convert.ToDouble(fields[8]); atom.xyz.Y = Convert.ToDouble(fields[9]); atom.xyz.Z = Convert.ToDouble(fields[10]); atomInfoList.Add(atom); } } atomReader.Close(); return(atomInfoList.ToArray()); }
/// <summary> /// /// </summary> /// <param name="atom"></param> /// <param name="atomId"></param> /// <returns></returns> public string FormatAtomLineAuthResidueNumbering(AtomInfo atom, string chainId, int atomId) { string atomLineHeader = "ATOM "; string atomLine = FormatAtomLineAuthResidueNumbering(atomLineHeader, atom, chainId, atomId); return(atomLine); }
/// <summary> /// input 2 sequence ids, output the distance between 2 /// sequence search, the atom list is not long /// </summary> /// <param name="seqId1"></param> /// <param name="seqId2"></param> /// <returns></returns> public double DistForSeqIds(string seqString) { string[] seqIds = seqString.Split('_'); if (chain1 == null || chain2 == null) { return(-1); } AtomInfo atom1 = null; AtomInfo atom2 = null; foreach (AtomInfo atom in chain1) { if (atom.seqId == seqIds[0]) { atom1 = atom; break; } } foreach (AtomInfo atom in chain2) { if (atom.seqId == seqIds[1]) { atom2 = atom; break; } } if (atom1 == null || atom2 == null) { return(-1); } return(atom1 - atom2); }
public void SetAtomA(Atom atom) { if (atom != null && atomChoices.Count > atom.GetAtomicNumber()) { ChoiceOption choiceOption = atomChoices[atom.GetAtomicNumber() - 1]; choiceOption.SetButtonEvent(() => { RemoveAtomA(); AudioManager.Instance.PlaySound(choiceClickSound); }); choiceOption.SetColors(ChoiceOption.defaultPressedColor, ChoiceOption.defaultHoverColor, ChoiceOption.defaultNormalColor); choiceOption.SetFocus(false); } atomA = atom; //atomChoices[atomA.GetAtomicNumber() - 1].SetInteractable(false); AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber()); AtomData data = Game.Instance.gameData.FindAtomData(atom.GetAtomicNumber()); atomAText.text = info.GetAtom().GetName(); atomAImage.sprite = info.GetImage(); atomAAmo.maxValue = data.GetCurrAmo(); SetAtomAAmoText(); atomABtn.interactable = true; }
/// <summary> /// deep copy constructor /// </summary> /// <param name="extNode"></param> public Node(Node extNode) { atomList = new AtomInfo [extNode.atomList.Length]; for (int i = 0; i < atomList.Length; i++) { atomList[i] = new AtomInfo((extNode.atomList)[i]); } boundBox = new BoundingBox(extNode.boundBox); }
public Node(AtomInfo[] inAtomList) { atomList = new AtomInfo[inAtomList.Length]; for (int i = 0; i < inAtomList.Length; i++) { atomList[i] = new AtomInfo(inAtomList[i]); } boundBox = new BoundingBox(inAtomList); }
/// <summary> /// /// </summary> /// <param name="lastAtom"></param> /// <param name="chainId"></param> /// <param name="atomId"></param> /// <returns></returns> public string FormatLastAtomLineInAuthResidueNumbering(AtomInfo lastAtom, string chainId, int atomId) { string line = "TER "; line += atomId.ToString().PadLeft(5, ' '); line += " "; line += lastAtom.authResidue.PadLeft(3, ' '); line += " "; line += chainId; line += lastAtom.authSeqId.PadLeft(4, ' '); return(line); }
/// <summary> /// residue centers, used to build the BV tree /// </summary> /// <param name="residues"></param> /// <returns></returns> private AtomInfo[] GetResidueCentersAtoms(Residue[] residues) { AtomInfo[] atoms = new AtomInfo [residues.Length]; for (int i = 0; i < residues.Length; i++) { atoms[i] = new AtomInfo(); atoms[i].residue = residues[i].ResidueName; atoms[i].seqId = residues[i].SeqID; atoms[i].xyz = residues[i].Center; } return(atoms); }
public static void CreateAtomInfo(Atom a) { AtomInfo aI = AtomInfo.CreateNewAtomInfo(a); string atomInfoPathName = AssetDatabase.GenerateUniqueAssetPath("Assets/Prefabs/ScriptableObjects/AtomInfo/" + a.GetAtomicNumber() + a.GetName() + "Info.asset"); AssetDatabase.CreateAsset(aI, atomInfoPathName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.FocusProjectWindow(); }
public ResidueNode(Residue[] residues) { residueList = residues; ArrayList atomsList = new ArrayList(); foreach (Residue residue in residues) { atomsList.AddRange(residue.Atoms); } atomList = new AtomInfo [atomsList.Count]; atomsList.CopyTo(atomList); boundBox = new BoundingBox(atomList); }
/// <summary> /// Calpha, Cbeta atoms /// </summary> /// <returns></returns> public AtomInfo[] CalphaCbetaAtoms() { ArrayList bbAtomList = new ArrayList(); foreach (AtomInfo atom in atomList) { if (atom.atomName == "CB" || atom.atomName == "CA") { bbAtomList.Add(atom); } } AtomInfo[] atoms = new AtomInfo [bbAtomList.Count]; bbAtomList.CopyTo(atoms); return(atoms); }
/// <summary> /// /// </summary> /// <param name="domainInfo"></param> private AtomInfo[] ChangeDomainAtomsSeqAtomIds(PfamDomainInfo domainInfo) { int atomSeqNo = 1; int residueSeqNo = 1; int atomSeqId = 0; int preAtomSeqId = 0; ArrayList domainAtomList = new ArrayList(); foreach (DomainSegmentInfo segInfo in domainInfo.segmentInfos) { atomSeqId = 0; preAtomSeqId = 0; segInfo.fileStart = residueSeqNo; segInfo.fileEnd = residueSeqNo + segInfo.seqEnd - segInfo.seqStart; for (int i = 0; i < segInfo.atoms.Length; i++) { segInfo.atoms[i].atomId = atomSeqNo; atomSeqNo++; if (atomSeqNo > 99999) // the maximum atom seq id is 5-digit { atomSeqNo = 1; } atomSeqId = Convert.ToInt32(segInfo.atoms[i].seqId); if (preAtomSeqId == 0) { preAtomSeqId = atomSeqId; } if (preAtomSeqId == atomSeqId) { segInfo.atoms[i].seqId = residueSeqNo.ToString(); } else { residueSeqNo = residueSeqNo + atomSeqId - preAtomSeqId; segInfo.atoms[i].seqId = residueSeqNo.ToString(); preAtomSeqId = atomSeqId; } } domainAtomList.AddRange(segInfo.atoms); residueSeqNo = segInfo.fileEnd + 1; } AtomInfo[] domainAtoms = new AtomInfo[domainAtomList.Count]; domainAtomList.CopyTo(domainAtoms); return(domainAtoms); }
/// <summary> /// /// </summary> /// <param name="chainAtoms"></param> /// <param name="domainRanges"></param> /// <returns></returns> private AtomInfo[] GetRegionAtomInfos(AtomInfo[] chainAtoms, Range[] domainRanges) { List <AtomInfo> atomList = new List <AtomInfo> (); int seqId = 0; foreach (AtomInfo atom in chainAtoms) { seqId = Convert.ToInt32(atom.seqId); if (IsResidueInDomainRanges(seqId, domainRanges)) { atomList.Add(atom); } } AtomInfo[] domainAtoms = new AtomInfo[atomList.Count]; atomList.CopyTo(domainAtoms); return(domainAtoms); }
/// <summary> /// the domain in the chain /// </summary> /// <param name="chain"></param> /// <param name="startPos"></param> /// <param name="endPos"></param> /// <returns></returns> private AtomInfo[] GetDomainAtoms(AtomInfo[] chain, int startPos, int endPos) { List <AtomInfo> atomList = new List <AtomInfo> (); int seqId = -1; foreach (AtomInfo atom in chain) { seqId = ParseHelper.ConvertSeqToInt(atom.seqId); if (seqId <= endPos && seqId >= startPos) { atomList.Add(atom); } } AtomInfo[] domain = new AtomInfo[atomList.Count]; atomList.CopyTo(domain); return(domain); }
/// <summary> /// /// </summary> /// <param name="domainEntityInfo"></param> /// <param name="chainInfo"></param> /// <returns></returns> private AtomInfo[] GetDomainSegmentAtoms(DomainSegmentInfo domainEntityInfo, ChainAtoms chainInfo) { ArrayList domainAtomList = new ArrayList(); int seqId = -1; foreach (AtomInfo atom in chainInfo.CartnAtoms) { seqId = Convert.ToInt16(atom.seqId); if (seqId >= domainEntityInfo.seqStart && seqId <= domainEntityInfo.seqEnd) { // AddAtomToList(atom, domainAtomList); domainAtomList.Add(atom); } } AtomInfo[] domainAtoms = new AtomInfo[domainAtomList.Count]; domainAtomList.CopyTo(domainAtoms); return(domainAtoms); }
/// <summary> /// /// </summary> /// <param name="atom"></param> /// <param name="atomId"></param> /// <returns></returns> public string FormatAtomLineAuthResidueNumbering(string lineHeader, AtomInfo atom, string chainId, int atomId) { string pdbAtomLine = lineHeader; string atomIdStr = atomId.ToString(); pdbAtomLine += atomIdStr.PadLeft(5, ' '); pdbAtomLine += " "; string atomName = atom.atomName; if (atomName != "" /* && atom.atomType != "H" */ && atom.atomName.Length < 4) { atomName = " " + atomName; } pdbAtomLine += atomName.PadRight(4, ' '); pdbAtomLine += " "; pdbAtomLine += atom.authResidue.PadLeft(3, ' '); pdbAtomLine += " "; pdbAtomLine += chainId; pdbAtomLine += atom.authSeqId.PadLeft(4, ' '); pdbAtomLine += " "; pdbAtomLine += FormatDoubleString(atom.xyz.X, 4, 3); pdbAtomLine += FormatDoubleString(atom.xyz.Y, 4, 3); pdbAtomLine += FormatDoubleString(atom.xyz.Z, 4, 3); if (atom.occupancy != null) { pdbAtomLine += atom.occupancy.PadLeft(6, ' '); } else { pdbAtomLine += " 1.00"; } if (atom.bfactor != null) { pdbAtomLine += atom.bfactor.ToString().PadLeft(6, ' '); } else { pdbAtomLine += " 0.00"; } pdbAtomLine += " "; pdbAtomLine += atom.atomType + " "; return(pdbAtomLine); }
public static void CreateAtom(string name, string abbreviation, int atomicNumber) { Atom a = Atom.CreateNewAtom(name, abbreviation, atomicNumber); AtomInfo aI = AtomInfo.CreateNewAtomInfo(a); AtomData aD = AtomData.CreateNewAtomData(a); string atomPathName = AssetDatabase.GenerateUniqueAssetPath("Assets/Prefabs/ScriptableObjects/Atom/" + a.GetAtomicNumber() + a.GetName() + ".asset"); string atomInfoPathName = AssetDatabase.GenerateUniqueAssetPath("Assets/Prefabs/ScriptableObjects/AtomInfo/" + a.GetAtomicNumber() + a.GetName() + "Info.asset"); string atomDataPathName = AssetDatabase.GenerateUniqueAssetPath("Assets/Prefabs/ScriptableObjects/AtomData/" + a.GetAtomicNumber() + a.GetName() + "Data.asset"); AssetDatabase.CreateAsset(a, atomPathName); AssetDatabase.CreateAsset(aI, atomInfoPathName); AssetDatabase.CreateAsset(aD, atomDataPathName); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorUtility.FocusProjectWindow(); }
private void CreateChildPage2(Atom atom, Vector2 size) { AtomInfo info = Game.Instance.gameData.FindAtomInfo(atom.GetAtomicNumber()); if (info == null || (info.GetGroup() == 0 && info.GetPeriod() == 0)) { return; } // Instantiate ElementDisplay display = Instantiate(elementDisplayPrefab, this.transform); display.atom = atom; elementDisplays.Add(display); RectTransform child = display.GetComponent <RectTransform>(); // Grid Pos int gridX = info.GetGroup() - 1; int gridY = info.GetPeriod() - 1; // Pivot child.pivot = Vector2.up; // Anchor child.anchorMax = Vector2.up; child.anchorMin = Vector2.up; // Width and Height child.sizeDelta = size; // LocalPosition - Grid(0, 0) float x = size.x * gridX; float y = -size.y * gridY - size.y * 2.4f; child.anchoredPosition3D = new Vector3(x, y, .0f); var elementDiscovery = Instantiate(elementDiscoveryPrefab, elementDiscoveryParent); display.SetExclamationImage(elementDiscovery); }
/// <summary> /// /// </summary> /// <param name="protChainName"></param> /// <param name="ligandName"></param> /// <param name="protChainAtoms"></param> /// <param name="ligandAtoms"></param> public Dictionary <string, AtomInfo[]> CalculateAtomDistances(AtomInfo[] ligandAtoms, AtomInfo[] protChainAtoms, out Dictionary <string, double> seqPairDistanceHash) { seqPairDistanceHash = new Dictionary <string, double> (); Dictionary <string, AtomInfo[]> seqPairAtomInfoHash = new Dictionary <string, AtomInfo[]>(); string seqPair = ""; double distance = 0; foreach (AtomInfo ligandAtom in ligandAtoms) { foreach (AtomInfo protAtom in protChainAtoms) { seqPair = ligandAtom.seqId + "_" + protAtom.seqId; distance = GetDistance(ligandAtom.xyz, protAtom.xyz); if (distance > contactCutoff) { continue; } if (seqPairDistanceHash.ContainsKey(seqPair)) { double lsDistance = (double)seqPairDistanceHash[seqPair]; if (distance < lsDistance) { seqPairDistanceHash[seqPair] = distance; AtomInfo[] atomPairs = new AtomInfo[2]; atomPairs[0] = ligandAtom; atomPairs[1] = protAtom; seqPairAtomInfoHash[seqPair] = atomPairs; } } else { AtomInfo[] atomPairs = new AtomInfo[2]; atomPairs[0] = ligandAtom; atomPairs[1] = protAtom; seqPairAtomInfoHash.Add(seqPair, atomPairs); seqPairDistanceHash.Add(seqPair, distance); } } } return(seqPairAtomInfoHash); }
/// <summary> /// /// </summary> /// <param name="atom"></param> /// <param name="domainAtomList"></param> private void AddAtomToList(AtomInfo atom, ArrayList domainAtomList) { int i = -1; for (i = domainAtomList.Count - 1; i >= 0; i--) { if (atom.atomId > ((AtomInfo)domainAtomList[i]).atomId) { break; } } if (i == domainAtomList.Count - 1) { domainAtomList.Add(atom); } else { domainAtomList.Insert(i + 1, atom); } }
/// <summary> /// the domain in the chain /// </summary> /// <param name="chain"></param> /// <param name="startPos"></param> /// <param name="endPos"></param> /// <returns></returns> private AtomInfo[] GetDomainAtoms(AtomInfo[] chain, Range[] ranges) { List <AtomInfo> atomList = new List <AtomInfo> (); int seqId = -1; foreach (AtomInfo atom in chain) { seqId = ParseHelper.ConvertSeqToInt(atom.seqId); foreach (Range range in ranges) { if (seqId <= range.endPos && seqId >= range.startPos) { atomList.Add(atom); break; } } } AtomInfo[] domain = new AtomInfo[atomList.Count]; atomList.CopyTo(domain); return(domain); }
/// <summary> /// write a chain into a pdb formatted file /// </summary> /// <param name="chain">atoms</param> /// <param name="chainId">chain id</param> /// <param name="atomId">start atom sequential number for this chain</param> /// <param name="fileWriter">file id to write</param> public void WriteOneChainInAuthNumbering(AtomInfo[] chain, string chainId, ref int atomId, bool isLigand, StreamWriter fileWriter) { string lineHeader = ""; string line = ""; AtomInfo lastAtom = new AtomInfo(); string seqAtomName = ""; List <string> addedAtomsList = new List <string>(); foreach (AtomInfo atom in chain) { seqAtomName = atom.authSeqId + "_" + atom.authResidue + "_" + atom.atomName; if (addedAtomsList.Contains(seqAtomName)) { continue; } atomId++; if (atomId > maxAtomId) { atomId = 1; } if (isLigand) { lineHeader = "HETATM"; } else { lineHeader = "ATOM "; } line = FormatAtomLineAuthResidueNumbering(lineHeader, atom, chainId, atomId); fileWriter.WriteLine(line); lastAtom = atom; addedAtomsList.Add(seqAtomName); } if (!isLigand) { atomId++; line = FormatLastAtomLineInAuthResidueNumbering(lastAtom, chainId, atomId); fileWriter.WriteLine(line); } }
/// <summary> /// return the atom for the input sequence id /// </summary> /// <param name="seqId"></param> /// <param name="dim">chain1 or chain2</param> /// <returns></returns> public AtomInfo GetAtom(string seqId, int dim) { AtomInfo theAtom = null; switch (dim) { case 1: { foreach (AtomInfo atom in chain1) { if (atom.seqId == seqId) { theAtom = atom; break; } } break; } case 2: { foreach (AtomInfo atom in chain2) { if (atom.seqId == seqId) { theAtom = atom; break; } } break; } default: { break; } } return(theAtom); }
/// <summary> /// update the tree to another tree with exactly same structure /// using bottom-up /// </summary> /// <param name="extBvTree"></param> private void UpdateNodeBb(Dictionary <string, Residue> residueSeqHash) { AtomInfo[] residueCenters = this.Root.AtomList; List <AtomInfo> atomList = new List <AtomInfo> (); foreach (AtomInfo residueCenter in residueCenters) { Residue residue = ((Residue)residueSeqHash[residueCenter.seqId]); atomList.AddRange(residue.Atoms); } AtomInfo[] atoms = new AtomInfo [atomList.Count]; atomList.CopyTo(atoms); this.Root.AtomList = atoms; this.Root.BoundBox = new BoundingBox(atoms); if (this.leftBranch == null && this.rightBranch == null) { return; } this.leftBranch.UpdateNodeBb(residueSeqHash); this.rightBranch.UpdateNodeBb(residueSeqHash); }
protected override void Visit(MoleculeSyntax molecule) { if (molecule.IsAbstract) return; var atoms = molecule.Atoms.Select(GetAtomInfo).Concat(GetBaseAtomInfo(molecule)); Write($"protected void Apply{molecule.Name}("); Delimit(atoms, "parameter", ", "); WriteLine(")"); using (WithBlock()) { WriteLine($"if (Version <= 0) throw new InvalidOperationException(\"This overload of Apply{molecule.Name} can only be called after the first event is applied. Please call the overload which requires the Aggregate's ID to be provided.\");"); WriteLine(); Write($"ApplyEvent(new {molecule.Name}("); Delimit(atoms, "argument", ", "); WriteLine($"{(atoms.Any() ? ", " : "")}Id, Version + 1));"); } var aggregate = (AggregateSyntax)molecule.Parent; var id = aggregate.GetIdTypeName(SymbolTable); var idAtom = new AtomInfo(Syntax.IdentifierName("id"), new TypeReferenceSyntax(id, new TypeCardinalitySyntax(1, 1)), true); atoms = atoms.Concat(new[] { idAtom }); Write($"protected void Apply{molecule.Name}("); Delimit(atoms, "parameter", ", "); WriteLine(")"); using (WithBlock()) { Write($"ApplyEvent(new {molecule.Name}("); Delimit(atoms, "argument", ", "); WriteLine($", Version + 1));"); } }