summaryrefslogtreecommitdiff
path: root/Code
diff options
context:
space:
mode:
authorLan Hui <lanhui@zjnu.edu.cn>2025-10-28 16:14:13 +0800
committerLan Hui <lanhui@zjnu.edu.cn>2025-10-28 16:14:13 +0800
commitfafb342fe7e756c7a23b9d371565f089afdf18bd (patch)
tree515330f435a62a6d8b18045614a96e83322b6451 /Code
parentb711f8723524f2fab8ee7e84645f4a9724a8576c (diff)
Map experiment ID to library strategy and library source
Diffstat (limited to 'Code')
-rw-r--r--Code/make_experiment_library_info_file.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Code/make_experiment_library_info_file.py b/Code/make_experiment_library_info_file.py
new file mode 100644
index 0000000..9578945
--- /dev/null
+++ b/Code/make_experiment_library_info_file.py
@@ -0,0 +1,22 @@
+# Usage: python3 make_experiment_library_info_file.py
+#
+# Purpose: build a file (see EXPERIMENT_LIBRARY_INFO_FILE) that tells whether an experiment is RNA-seq.
+#
+# 2025-10-28, hui
+
+from configure import EXPERIMENT_LIBRARY_INFO_FILE, EXPERIMENT_INFO_DIR
+from parse_ena_xml import parse_experiment
+import glob, os
+
+result = []
+for fname in sorted(glob.glob(os.path.join(EXPERIMENT_INFO_DIR, '*'))):
+ _, experiment_id = os.path.split(fname)
+ d = parse_experiment(fname)
+ result.append([experiment_id, d[experiment_id]['library_strategy'], d[experiment_id]['library_source']])
+
+print(f'Saving to {EXPERIMENT_LIBRARY_INFO_FILE}')
+with open(EXPERIMENT_LIBRARY_INFO_FILE, 'a') as f:
+ for x in result:
+ f.write('\t'.join(x) + '\n')
+print('Done. Saved %d lines.' % (len(result)))
+