//�Private�Methods�(3)� /// <summary> /// Checks for boxing. /// </summary> /// <param name="customTypeList">The custom type list.</param> private void CheckForBoxing(List <MethodInfo> customTypeList) { foreach (var item in customTypeList) { try { //Checking if a method attribute has DLLImport which will be ignored. if (item.GetCustomAttributes(typeof(DllImportAttribute), false).Length > 0) { continue; } var boxOpCodeList = new MethodBodyAnalyzer().GetMethodBodyInILFormat(item).FindAll(opCodeItem => opCodeItem.OpCode == OpCodes.Box) as List <ILInstructionFormat>; var pdbSourceData = new PDBReader(_symbolreader).GetMethodSourceFromPDB(item); FetchSourceLines(boxOpCodeList, pdbSourceData, item); } //It is ok to suppress since for some methods, its source code can not be read or //information can not be read from pdb. catch (COMException) { } catch (ExternalException) { } } }
public void TestSFBug1085912_1() { string filename_pdb = "NCDK.Data.PDB.1CKV.pdb"; var ins1 = ResourceLoader.GetAsStream(this.GetType(), filename_pdb); ISimpleChemObjectReader reader = new PDBReader(ins1); IChemFile chemFile1 = (IChemFile)reader.Read(builder.NewChemFile()); reader.Close(); IChemSequence seq1 = chemFile1[0]; IChemModel model1 = seq1[0]; IAtomContainer container = model1.MoleculeSet[0]; IBioPolymer polymer1 = (IBioPolymer)container; int countchemFile1 = chemFile1.Count; int countmodel1 = model1.MoleculeSet.Count; int countpolymer1 = polymer1.Atoms.Count; StringWriter writer = new StringWriter(); CMLWriter cmlWriter = new CMLWriter(writer); cmlWriter.RegisterCustomizer(new PDBAtomCustomizer()); cmlWriter.Write(polymer1); cmlWriter.Close(); string cmlContent1 = writer.ToString(); CMLReader reader2 = new CMLReader(new MemoryStream(Encoding.UTF8.GetBytes(cmlContent1))); var chemFil2 = reader2.Read(builder.NewChemFile()); reader2.Close(); IChemSequence seq2 = chemFil2[0]; IChemModel model2 = seq2[0]; var polymer2 = (IPDBPolymer)model2.MoleculeSet[0]; int countchemFile2 = chemFil2.Count; int countmodel2 = model2.MoleculeSet.Count; int countpolymer2 = polymer2.Atoms.Count; Assert.AreEqual(countchemFile1, countchemFile2); Assert.AreEqual(countmodel1, countmodel2); Assert.AreEqual(countpolymer1, countpolymer2); writer = new StringWriter(); cmlWriter = new CMLWriter(writer); cmlWriter.RegisterCustomizer(new PDBAtomCustomizer()); cmlWriter.Write(polymer2); cmlWriter.Close(); string cmlContent2 = writer.ToString(); string conte1 = cmlContent1.Substring(0, 1000); string conte2 = cmlContent2.Substring(0, 1000); Assert.AreEqual(conte1, conte2); }
public void TestCranbinSurface() { var bldr = CDK.Builder; IChemFile chemFile; var path = "NCDK.Data.PDB.1CRN.pdb"; using (var pdbr = new PDBReader(ResourceLoader.GetAsStream(path))) { chemFile = pdbr.Read(bldr.NewChemFile()); var mol = ChemFileManipulator.GetAllAtomContainers(chemFile).ElementAt(0); var surface = new NumericalSurface(mol); var map = surface.GetAtomSurfaceMap(); Assert.AreEqual(222, map.Count); Assert.AreEqual(327, mol.Atoms.Count); } }
public void ReadPDB() { PDBReader reader = new PDBReader(this.fileName); foreach (ClassDef cDef in GetClasses()) { foreach (MethodDef mDef in cDef.GetMethods()) { CILInstructions buffer = mDef.GetCodeBuffer(); PDBMethod meth = reader.GetMethod((int)mDef.Token()); if (meth == null) { continue; // no symbols for this method } PDBSequencePoint[] spList = meth.SequencePoints; MergeBuffer mergeBuffer = new MergeBuffer(buffer.GetInstructions()); PDBScope outer = meth.Scope; Scope root = ReadPDBScope(outer, mergeBuffer, null, mDef); buffer.currentScope = root; bool hasRootScope = mergeBuffer.hasRootScope(); if (!hasRootScope) { mergeBuffer.Add(new OpenScope(root), (uint)0); } foreach (PDBSequencePoint sp in spList) { PDBDocument doc = sp.Document; mergeBuffer.Add( new Line((uint)sp.Line, (uint)sp.Column, (uint)sp.EndLine, (uint)sp.EndColumn, SourceFile.GetSourceFile(doc.URL, doc.Language, doc.LanguageVendor, doc.DocumentType)), (uint)sp.Offset); } if (!hasRootScope) { mergeBuffer.Add(new CloseScope(root), (uint)outer.EndOffset); } buffer.SetInstructions(mergeBuffer.Instructions); } } }
public void makeProtein(string filename) { //Uses PDBReader to read a file //Then extracts the information needed to instantiate the protein PDBReader reader = new PDBReader(); reader.readFile(filename); AtomData[] proteinAtoms = reader.getProteinAtoms(); AtomData[] extraAtoms = reader.getExtraAtoms(); string[] aminoAcidCodes = reader.getAminoAcidCodes(); BondData[] extraBonds = reader.getExtraBonds(); //Gets instance of ProteinHelper helper = ProteinHelper.getHelperInstance(); //Initalizes array of atoms atoms = new GameObject[proteinAtoms.Length + extraAtoms.Length]; int i = 0; //Instantiates atoms present in amino acids and adds object to array of Atoms foreach (AtomData atom in proteinAtoms) { atoms[i++] = createAtom(atom.x, atom.y, atom.z, helper.getColor(atom.element)); } //Instantiates atoms not present in amino acids and adds object to array of Atoms foreach (AtomData atom in extraAtoms) { atoms[i++] = createAtom(atom.x, atom.y, atom.z, helper.getColor(atom.element)); } //Instantiates bonds present in amino acid sequence and adds them to array of bonds List <GameObject> bonds = new List <GameObject>(); BondData[] bondData; i = 0; int previousEnd = 0; foreach (string aminoAcid in aminoAcidCodes) { //Instantiates bonds in the backbone of the amino acid bonds.Add(createBond(atoms[i], atoms[i + 1])); bonds.Add(createBond(atoms[i + 1], atoms[i + 2])); bonds.Add(createBond(atoms[i + 2], atoms[i + 3])); //should be a double bond in future //Instantiates bond connecting current amino acid to previous one if (previousEnd != 0) { bonds.Add(createBond(atoms[previousEnd], atoms[i])); } //Grabs bonds in R group of current amino acid bondData = helper.getRGroupBonds(aminoAcid); //Instantiates each of the bonds in the R group foreach (BondData bond in bondData) { bonds.Add(createBond(atoms[i + bond.atom1Index], atoms[i + bond.atom2Index])); } //Increases iterator and stores carboxyl end for next amino acid previousEnd = i + 2; i += helper.getNumAtoms(aminoAcid); } //Instantiates bonds not present in amino acid sequence and adds them to list of bonds foreach (BondData bond in extraBonds) { bonds.Add(createBond(atoms[bond.atom1Index], atoms[bond.atom2Index])); } this.bonds = bonds.ToArray(); }
public void ReadPDB() { PDBReader reader = new PDBReader(this.fileName); foreach (ClassDef cDef in GetClasses()) foreach (MethodDef mDef in cDef.GetMethods()) { CILInstructions buffer = mDef.GetCodeBuffer(); PDBMethod meth = reader.GetMethod((int)mDef.Token()); if (meth == null) continue; // no symbols for this method PDBSequencePoint[] spList = meth.SequencePoints; MergeBuffer mergeBuffer = new MergeBuffer(buffer.GetInstructions()); PDBScope outer = meth.Scope; Scope root = ReadPDBScope(outer, mergeBuffer, null, mDef); buffer.currentScope = root; bool hasRootScope = mergeBuffer.hasRootScope(); if (!hasRootScope) mergeBuffer.Add(new OpenScope(root), (uint)0); foreach (PDBSequencePoint sp in spList) { PDBDocument doc = sp.Document; mergeBuffer.Add( new Line((uint)sp.Line, (uint)sp.Column, (uint)sp.EndLine, (uint)sp.EndColumn, SourceFile.GetSourceFile(doc.URL, doc.Language, doc.LanguageVendor, doc.DocumentType)), (uint)sp.Offset); } if (!hasRootScope) mergeBuffer.Add(new CloseScope(root), (uint)outer.EndOffset); buffer.SetInstructions(mergeBuffer.Instructions); } }