Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. diff --git a/src/dscience/biology/parser/Pdbml.d b/src/dscience/biology/parser/Pdbml.d
  2. index 2389f92..02211ee 100644
  3. --- a/src/dscience/biology/parser/Pdbml.d
  4. +++ b/src/dscience/biology/parser/Pdbml.d
  5. @@ -18,6 +18,7 @@ private import tango.io.Stdout;
  6.  
  7. alias Document!(char) XML;
  8.  
  9. +
  10. public class Pdbml{
  11. private File pdbml;
  12. private XmlPath!(char).NodeSet root;
  13. @@ -66,7 +67,7 @@ public class Pdbml{
  14. return molecules;
  15. }
  16.  
  17. - public IProtein getProtein(uint model, size_t entity_id, char[][][]peptides ...){
  18. + public IProtein getProtein(uint model, size_t entity_id, char[][][]peptides){
  19. auto struct_ref_seqCategory = root.descendant("struct_ref_seqCategory");
  20. auto struct_ref_seq = struct_ref_seqCategory.child("struct_ref_seq").dup;
  21. IMolecule[][] molecules = new IMolecule[][](peptides.length);
  22. @@ -85,7 +86,7 @@ public class Pdbml{
  23. }
  24. }
  25. molecules.length = index;
  26. - createDisulfideBond(molecules, strands);
  27. + /*createDisulfideBond*/ helper(molecules, strands);
  28. IProtein protein = new Protein(proteinName, molecules);
  29. protein.doPeptideBond();
  30. return protein;
  31. @@ -179,13 +180,31 @@ public class Pdbml{
  32. }
  33. }
  34. }
  35. -
  36. - private void createDisulfideBond(IMolecule[][] molecules, uint[char[]] strands){
  37. +
  38. + void helper(IMolecule[][] molecules, uint[char[]] strands)
  39. + {
  40. + bool myFilter(XML.Node n)
  41. + {
  42. + /*
  43. + //segfaults
  44. + bool a1 = (n.query.child("conn_type_id").nodes[0].value == "disulf");
  45. + bool a2 = (n.query.child("ptnr1_label_asym_id").nodes[0].value in strands) !is null;
  46. + bool a3 = (n.query.child("ptnr2_label_asym_id").nodes[0].value in strands) !is null;
  47. + return a1 && a2 && a3;
  48. + */
  49. + //works
  50. + return n.query.child("conn_type_id").nodes[0].value == "disulf" &&
  51. + (n.query.child("ptnr1_label_asym_id").nodes[0].value in strands && n.query.child("ptnr2_label_asym_id").nodes[0].value in strands);
  52. + }
  53. auto struct_connCategory = root.descendant("struct_connCategory");
  54. - auto struct_conn = struct_connCategory.child("struct_conn").filter((XML.Node n) {
  55. - return n.query.child("conn_type_id").nodes[0].value == "disulf" && (n.query.child("ptnr1_label_asym_id").nodes[0].value in strands && n.query.child("ptnr2_label_asym_id").nodes[0].value in strands);
  56. - }).dup;
  57. - foreach(molecule; struct_conn){
  58. + auto struct_conn = struct_connCategory.child("struct_conn").filter(&myFilter).dup;
  59. + createDisulfideBond(molecules, strands, struct_conn);
  60. + }
  61. +
  62. + void createDisulfideBond(IMolecule[][] molecules, uint[char[]] strands, XmlPath!(char).NodeSet struct_conn)
  63. + {
  64. + foreach(molecule; struct_conn)
  65. + {
  66. size_t molecule1Index = Convert.to!(size_t)(molecule.query.child("ptnr1_label_seq_id").nodes[0].value) - 1;
  67. size_t molecule2Index = Convert.to!(size_t)(molecule.query.child("ptnr2_label_seq_id").nodes[0].value) - 1;
  68. char[] ptnr1_label_asym_id = molecule.query.child("ptnr1_label_asym_id").nodes[0].value;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement