Skip to content

Commit

Permalink
adjusting bh23 workbook, and model class
Browse files Browse the repository at this point in the history
  • Loading branch information
proccaserra committed Aug 5, 2024
1 parent 00c2f63 commit 339db38
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 204 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
" ### Loading the ISA-API"
"### Loading the ISA-API"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from isatools.model import (\n",
Expand Down Expand Up @@ -53,9 +51,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"investigation = Investigation()\n",
Expand Down Expand Up @@ -223,9 +219,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"study.sources = [Source(name=\"GSM255770\"), Source(name=\"GSM255771\"),Source(name=\"GSM255772\"),Source(name=\"GSM255773\")]\n",
Expand Down Expand Up @@ -268,9 +262,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# Starting by declaring the 2 types of assays used in BII-S-3 as coded with ISAcreator tool\n",
Expand Down Expand Up @@ -308,9 +300,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"\n",
Expand Down Expand Up @@ -435,9 +425,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"study.assays.append(assay)\n",
Expand All @@ -447,9 +435,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# assay_g = investigation.studies[0].assays[1]\n",
Expand Down Expand Up @@ -506,9 +492,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from isatools.isatab import dump\n",
Expand All @@ -527,9 +511,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"from isatools.isatab import load\n",
Expand Down Expand Up @@ -581,9 +563,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"# import hashlib\n",
Expand All @@ -594,9 +574,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"import filecmp\n",
Expand All @@ -607,9 +585,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"filecmp.cmp('./output/BII-S-3-synth/s_BII-S-3-synthesis.txt', './notebook-output/BII-S-3-roundtrip/s_BII-S-3-synthesis.txt')"
Expand All @@ -618,9 +594,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"filecmp.cmp('./output/BII-S-3-synth/a_gilbert-assay-Gx.txt', './notebook-output/BII-S-3-roundtrip/a_gilbert-assay-Gx.txt')"
Expand All @@ -629,9 +603,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"filecmp.cmp('./output/BII-S-3-synth/a_gilbert-assay-Tx.txt', './notebook-output/BII-S-3-roundtrip/a_gilbert-assay-Tx.txt')"
Expand Down
13 changes: 5 additions & 8 deletions isatools/model/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import itertools

import networkx as nx
import os

from isatools.model.datafile import DataFile
from isatools.model.process import Process
Expand Down Expand Up @@ -60,7 +58,6 @@ def _expand_path(path, identifiers_to_objects, dead_end_outputs):
path_modified = False
for i, identifier in enumerate(path):
node = identifiers_to_objects[identifier]

# If the node is a process at beginning of the path, add a path for each of its inputs.
if i == 0 and isinstance(node, Process):
identifier_list = [input_.sequence_identifier for input_ in node.inputs]
Expand Down Expand Up @@ -90,7 +87,7 @@ def _expand_path(path, identifiers_to_objects, dead_end_outputs):
output_sequence_identifiers = {output.sequence_identifier for output in node.outputs}
input_sequence_identifiers = {input_.sequence_identifier for input_ in
identifiers_to_objects[path[i + 1]].inputs}
identifier_intersection = output_sequence_identifiers.intersection(input_sequence_identifiers)
identifier_intersection = list(output_sequence_identifiers.intersection(input_sequence_identifiers))

combinations = _compute_combinations(identifier_intersection, identifiers_to_objects)
for combo in combinations:
Expand Down Expand Up @@ -206,6 +203,7 @@ def _build_paths_and_indexes(process_sequence=None):

return paths, identifiers_to_objects


def _build_assay_graph(process_sequence=None):
""":obj:`networkx.DiGraph` Returns a directed graph object based on a
given ISA process sequence."""
Expand Down Expand Up @@ -289,7 +287,7 @@ def batch_create_assays(*args, n=1):
from a prototype sequence (currently works only as flat end-to-end
processes of Material->Process->Material->...)
:param *args: An argument list representing the process sequence prototype
# :param *args: An argument list representing the process sequence prototype
:param n: Number of process sequences to create in the batch
:returns: List of process sequences replicating the prototype sequence
Expand Down Expand Up @@ -376,13 +374,13 @@ def batch_create_assays(*args, n=1):
if isinstance(material_a, list):
process.inputs = material_a
else:
process.inputs.append(material_a)
process.inputs = [material_a] # /.append(material_a)
if isinstance(material_b, list):
process.outputs = material_b
for material in material_b:
material.derives_from = [material_a]
else:
process.outputs.append(material_b)
process.outputs = [material_b] # .append(material_b)
material_b.derives_from = [material_a]
process_sequence.append(process)
material_a = material_b
Expand All @@ -402,4 +400,3 @@ def _deep_copy(isa_object):
if isinstance(isa_object, ProcessSequenceNode):
new_obj.assign_identifier()
return new_obj

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"id": "https://raw.githubusercontent.com/ISA-tools/isa-api/master/isatools/resources/schemas/isa_model_version_1_0_schemas/core/comment_schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISA Comment schema - it corresponds to ISA Comment[] construct",
Expand Down

0 comments on commit 339db38

Please sign in to comment.