1. Hanfei Sun
  2. MISP

Commits

Hanfei Sun  committed a3d6889 Draft

add script to parse annotation

  • Participants
  • Parent commits 0d9377f
  • Branches default

Comments (0)

Files changed (1)

File scripts/cistrome-xml-anno-parse.py

View file
  • Ignore whitespace
+from xml.etree import ElementTree
+import sys
+# Usage: python3 cistrome-xml-parse.py ../database/cistrome.xml > ../database/newdb.db
+def print_findall(xPath, node,
+                  extract=lambda x:x.text.strip(),
+                  sep=" ",
+                  end="\n"):
+
+    print(sep.join(map(extract,node.findall(xPath))),end=end)
+
+if __name__ == '__main__':
+    if len(sys.argv) < 2:
+        print("please assign an xml file")
+    else:
+        tree = ElementTree.parse(sys.argv[1])
+        for node in tree.findall('.//motif'):
+            print(node.attrib["id"],end="\t")
+            print_findall(".//symbol",node,end="\t",sep=",")
+            print_findall(".//synonym",node,sep=",")