private static PDBFile pdbReadCore(StreamReader reader) { var pdb = new PDBFile(); var currentAA = new Residue(pdb); var currentChain = new Chain(); var currentResidue = ""; var chain = ""; string line = ""; while ((line = reader.ReadLine()) != null) { if (line.StartsWith("ATOM")) { var chaintemp = line.Substring(21, 1); if (!chaintemp.Equals(chain)) { chain = chaintemp; currentChain = new Chain(); currentChain.Name = chain; currentChain.PDB = pdb; pdb.Chains.Add(currentChain); } var residue = line.Substring(22, 5).Trim(); if (!residue.Equals(currentResidue)) { currentResidue = residue; currentAA = new Residue(pdb); currentChain.Residues.AddLast(currentAA); currentAA.Code = line.Substring(17, 3); currentAA.Id = residue; currentAA.Chain = chain; } var atom = new Atom(); atom.Residue = currentAA; atom.Id = line.Substring(6, 5); atom.Name = line.Substring(12, 4).Trim(); atom.Element = line.Substring(76, 2).Trim(); atom.TemperatureFactor = double.Parse(line.Substring(60, 6), CultureInfo.InvariantCulture); //check for CAlpha if (atom.Name.Contains("CA")) { currentAA.CAlpha = atom; } atom.X = double.Parse(line.Substring(30, 8), CultureInfo.InvariantCulture); atom.Y = double.Parse(line.Substring(38, 8), CultureInfo.InvariantCulture); atom.Z = double.Parse(line.Substring(46, 8), CultureInfo.InvariantCulture); //pdb.Atoms.AddLast(atom); currentAA.Atoms.AddLast(atom); } else if (line.StartsWith("HEADER")) { pdb.Name = line.Substring(62, 4); } } return(pdb); }
public static Dictionary <string, ProteinGraph> Do(PDBFile file, double neighbourDistance, ResidueNodeCenterDefinition centerdef) { var dict = new Dictionary <string, ProteinGraph>(); foreach (var chain in file.Chains) { var graph = new ProteinGraph(); graph.Data = new ProteinGraphData(); graph.Data.PDBFile = file; graph.Data.NeighbourDistance = neighbourDistance; graph.Data.NodeCenterDefinition = centerdef; //Compute Nodes: foreach (var residue in chain.Residues) { if (residue.CAlpha != null) { var node = graph.CreateNode(); node.Data = new ResidueNodeData(residue); node.Data.IsCore = residue.IsCore; node.Data.ZScore = residue.ZScore; switch (centerdef) { case ResidueNodeCenterDefinition.CAlpha: node.Data.SetValuesTo(residue.CAlpha); break; case ResidueNodeCenterDefinition.BalancePoint: node.Data.SetValuesTo(residue.Atoms.BalancePoint()); break; default: break; } } } var nodeList = graph.Nodes.ToList(); //compute edges: for (int i = 0; i < nodeList.Count - 1; i++) { for (int k = i + 1; k < nodeList.Count; k++) { var nodeOne = nodeList[i]; var nodetwo = nodeList[k]; var dist = nodeOne.Data.Distance(nodetwo.Data); if (dist <= neighbourDistance) { var edge = graph.CreateEdge(nodeOne, nodetwo); edge.Data = new SimpleEdgeData(); } } } dict.Add(chain.Name, graph); } return(dict); }
public Dictionary <string, Dictionary <Residue, bool> > Predict(PDBFile file, IDictionary <string, ProteinGraph> graphs) { if (TrainingPDBs.Any(pdb => pdb.Equals(file.Name))) { Log.Post("This PDB was used to train this predictor."); } return(PredictionFunc(file, graphs)); }
private Dictionary <string, Dictionary <Residue, bool> > doPrediction(PDBFile file, IDictionary <string, ProteinGraph> graphs) { var dict = new Dictionary <string, Dictionary <Residue, bool> >(); var Feature = new AverageHydrophobicityFeature(); var req = new RequestRasa(file); req.RequestInDefaultContext(); var rasa = req.Rasavalues; //Threshold = 0.5; //foreach (var graph in graphs) //{ // Feature.Compute(graph.Value); // var valdict = new Dictionary<ResidueNode, double[]>(); // var edgeScores = new double[2, 2] { { 1.2, 0.6 }, { 0.6, 1.0 } }; // foreach (var node in graph.Value.Nodes) // { // var val = (Feature.ValueOf(node.Data.Residue) * rasa[node.Data.Residue]) / Max; // valdict.Add(node, new double[2] { val, 1 - val }); // } // var edgedict = new Dictionary<SimpleEdge<ResidueNode>, double[,]>(); // foreach (var edge in graph.Value.Edges) // { // edgedict.Add(edge, edgeScores); // } // var predDict = new Dictionary<Residue, bool>(); // dict.Add(graph.Key, predDict); // var crfGraph = graph.Value.CreateGraph(valdict, edgedict); // //var options = new MarginalizeByResamplingOptions(2, 200); // //foreach (var node in crfNodes) // //{ // // var probs = MarginalizeByResampling.Do(crfNodes, node, options); // // predDict.Add(graph.Value.Nodes.First(nd => nd.Residue.Id.Equals(node.Id)).Residue, probs[0] >= Threshold); // //} // var result = SimpleSampling.Do(crfGraph, 2000); // foreach (var node in crfGraph.Nodes) // { // var score1 = result[new Assign() { Node = node, Label = 0 }]; // var score2 = result[new Assign() { Node = node, Label = 1 }]; // var prob = score2 / (score1 + score2); // predDict.Add(graph.Value.Nodes.First(nd => nd.Data.Residue.Id.Equals(node.Data.Id)).Residue, prob >= Threshold); // } //} return(dict); }
private Dictionary <string, Dictionary <Residue, bool> > doPrediction(PDBFile file, IDictionary <string, ProteinGraph> graphs) { var dict = new Dictionary <string, Dictionary <Residue, bool> >(); var Feature = new AverageHydrophobicityFeature(); var req = new RequestRasa(file); req.RequestInDefaultContext(); var rasa = req.Rasavalues; foreach (var graph in graphs) { Feature.Compute(graph.Value); var predDict = new Dictionary <Residue, bool>(); dict.Add(graph.Key, predDict); foreach (var node in graph.Value.Nodes) { predDict.Add(node.Data.Residue, (Feature.ValueOf(node.Data.Residue) * rasa[node.Data.Residue]) / Max >= Threshold); } } return(dict); }
public RequestRasa(PDBFile file) { File = file; Rasavalues = new Dictionary <Residue, double>(); }
public DoPrediction(PDBFile file, IDictionary <string, ProteinGraph> graphs) { File = file; Graphs = graphs; }
public static Dictionary <string, Dictionary <Residue, bool> > Predict(this IHas <IPredictionLogic> logicHolder, PDBFile file, IDictionary <string, ProteinGraph> graphs) { return(logicHolder.Logic.Predict(file, graphs)); }
public ComputeInterface(PDBFile pdb, double distance, bool useVanDerWaalsRadii) { Distance = distance; UseVanDerWaalsRadii = useVanDerWaalsRadii; PDB = pdb; }
public static Dictionary <string, LinkedList <Residue> > Do(PDBFile pdb, double distance, bool useVanDerWaalsRadii) { var iface = new Dictionary <string, LinkedList <Residue> >(); for (int i = 0; i < pdb.Chains.Count; i++) { var chain1 = pdb.Chains[i]; iface.Add(chain1.Name, new LinkedList <Residue>()); } for (int i = 0; i < pdb.Chains.Count; i++) { var chain1 = pdb.Chains[i]; var otherchains = pdb.Chains.ToList(); otherchains.Remove(chain1); var allotheratoms = otherchains.SelectMany(chain => chain.Atoms); foreach (var residue in chain1.Residues) { if (iface[chain1.Name].Contains(residue)) { continue; } bool isInterface = false; foreach (var atom in residue.Atoms) { foreach (var otherchain in otherchains) { foreach (var atomPartner in otherchain.Atoms) { if (isInterface) { break; } if (useVanDerWaalsRadii) { if (atom.Distance(atomPartner) <= +VanDerWaalsRadii.GetRadius(atom.Element) + VanDerWaalsRadii.GetRadius(atomPartner.Element) + distance) { isInterface = true; if (!iface[otherchain.Name].Contains(atomPartner.Residue)) { iface[otherchain.Name].Add(atomPartner.Residue); } } } else { if (atom.Distance(atomPartner) <= distance) { isInterface = true; if (!iface[otherchain.Name].Contains(atomPartner.Residue)) { iface[otherchain.Name].Add(atomPartner.Residue); } } } } } if (isInterface) { iface[chain1.Name].Add(residue); } } } } return(iface); }
public PDBInfo(PDBFile file) { file1 = file; file.Chains.Each(chain => ShowChain.Add(chain.Name, true)); }
public Residue(PDBFile pdb) { PDB = pdb; }