Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pinar Alper
metadata-tools
Commits
dc7c3cb8
Commit
dc7c3cb8
authored
May 29, 2018
by
Pinar Alper
Browse files
Added counting
parent
6ed65759
Changes
5
Hide whitespace changes
Inline
Side-by-side
tests/importxls/test_from_collab.py
View file @
dc7c3cb8
...
...
@@ -12,7 +12,7 @@ from tests.importxls.test_utils import get_value_list_from_row, process_data_typ
class
TestProjectsParser
(
TestCase
):
def
test_export_from_collaborator
(
self
):
h
=
hashlib
.
md5
()
count
=
0
for
dirName
,
subdirList
,
fileList
in
os
.
walk
(
SHEETS_FOLDER
):
for
fname
in
fileList
:
if
fname
.
startswith
(
'from-collaborator'
):
...
...
@@ -24,6 +24,7 @@ class TestProjectsParser(TestCase):
idx
=
1
#print('----> {}'.format(full_file_path))
while
idx
<
book
.
number_of_sheets
():
count
+=
1
sheet
=
book
.
sheet_by_index
(
idx
)
dataset_data
=
{}
dataset_data
[
'source_type'
]
=
'From_Collaborator'
...
...
@@ -39,6 +40,8 @@ class TestProjectsParser(TestCase):
if
sheet
[
7
,
2
]:
dataset_data
[
'samples_location'
]
=
sheet
[
7
,
2
]
if
dataset_data
[
'involves_samples'
]
==
False
:
print
(
'----> {}'
.
format
(
'Inconsistent samples information'
+
full_file_path
))
if
sheet
[
8
,
2
]:
dataset_data
[
'de_identification'
]
=
sheet
[
8
,
2
]
...
...
@@ -143,3 +146,4 @@ class TestProjectsParser(TestCase):
with
open
(
'datasets-{}.json'
.
format
(
submission_id
),
'w'
)
as
outfile
:
json
.
dump
(
dataset_list
,
outfile
,
indent
=
4
)
# print(json.dumps(dataset_list, indent=4))
print
(
'Number of Collab Datasets {}
\n
'
.
format
(
count
))
tests/importxls/test_from_repo.py
View file @
dc7c3cb8
...
...
@@ -13,6 +13,7 @@ class TestProjectsParser(TestCase):
def
test_export_from_repository
(
self
):
h
=
hashlib
.
md5
()
count
=
0
for
dirName
,
subdirList
,
fileList
in
os
.
walk
(
SHEETS_FOLDER
):
for
fname
in
fileList
:
...
...
@@ -25,6 +26,7 @@ class TestProjectsParser(TestCase):
idx
=
1
# print('----> {}'.format(full_file_path))
while
idx
<
book
.
number_of_sheets
():
count
+=
1
sheet
=
book
.
sheet_by_index
(
idx
)
dataset_data
=
{}
dataset_data
[
'source_type'
]
=
'From_Repository'
...
...
@@ -35,6 +37,9 @@ class TestProjectsParser(TestCase):
if
sheet
[
4
,
2
]:
dataset_data
[
'other_external_id'
]
=
sheet
[
4
,
2
]
if
sheet
[
5
,
2
]:
dataset_data
[
'title'
]
=
sheet
[
5
,
2
]
datatype_info
=
process_data_types
(
get_value_list_from_row
(
sheet
,
7
))
dataset_data
[
'data_types'
]
=
datatype_info
[
0
]
if
datatype_info
[
1
]:
...
...
@@ -107,3 +112,5 @@ class TestProjectsParser(TestCase):
with
open
(
'datasets-{}.json'
.
format
(
submission_id
),
'w'
)
as
outfile
:
json
.
dump
(
dataset_list
,
outfile
,
indent
=
4
)
# print(json.dumps(dataset_list, indent=4))
print
(
'Number of Repo Datasets {}
\n
'
.
format
(
count
))
tests/importxls/test_own_cohort.py
View file @
dc7c3cb8
...
...
@@ -13,6 +13,7 @@ class TestProjectsParser(TestCase):
def
test_export_own_cohort
(
self
):
h
=
hashlib
.
md5
()
count
=
0
for
dirName
,
subdirList
,
fileList
in
os
.
walk
(
SHEETS_FOLDER
):
for
fname
in
fileList
:
...
...
@@ -25,6 +26,7 @@ class TestProjectsParser(TestCase):
idx
=
1
print
(
'----> {}'
.
format
(
full_file_path
))
while
idx
<
book
.
number_of_sheets
():
count
+=
1
sheet
=
book
.
sheet_by_index
(
idx
)
dataset_data
=
{}
dataset_data
[
'source_type'
]
=
'Own_Cohort'
...
...
@@ -150,3 +152,5 @@ class TestProjectsParser(TestCase):
with
open
(
'datasets-{}.json'
.
format
(
submission_id
),
'w'
)
as
outfile
:
json
.
dump
(
dataset_list
,
outfile
,
indent
=
4
)
# print(json.dumps(dataset_list, indent=4))
print
(
'Number of Own-Cohort Datasets {}
\n
'
.
format
(
count
))
\ No newline at end of file
tests/importxls/test_projects.py
View file @
dc7c3cb8
...
...
@@ -26,7 +26,7 @@ class TestProjectsParser(TestCase):
idx
=
0
while
idx
<
book
.
number_of_sheets
():
if
idx
>
0
and
fname
.
startswith
(
'from-repository'
):
# print('---->{}'.format(fname))
prj_refs
=
set
(
get_value_list_from_row
(
book
.
sheet_by_index
(
idx
),
18
)
+
get_value_list_from_row
(
book
.
sheet_by_index
(
idx
),
19
))
...
...
@@ -35,7 +35,7 @@ class TestProjectsParser(TestCase):
print
(
'Reference to undefined project(s): {} in file {}'
.
format
(
undefined_refs
,
full_file_path
))
if
idx
>
0
and
fname
.
startswith
(
'from-collaborator'
):
# print('---->{}'.format(full_file_path))
prj_refs
=
set
(
get_value_list_from_row
(
book
.
sheet_by_index
(
idx
),
18
)
+
get_value_list_from_row
(
book
.
sheet_by_index
(
idx
),
26
)
+
get_value_list_from_row
(
book
.
sheet_by_index
(
idx
),
...
...
@@ -94,8 +94,10 @@ class TestProjectsParser(TestCase):
def
test_export_projects
(
self
):
projects_list
=
[]
count
=
0
for
acr
,
path
,
title
,
description
,
pi
,
start
,
end
,
personnel
,
HasUniLUERP
,
ERPNotes
,
HasCNER
,
CNERNotes
,
publications
in
collect_prj_info
(
SHEETS_FOLDER
):
count
+=
1
prj_data
=
{}
prj_data
[
'acronym'
]
=
acr
prj_data
[
'title'
]
=
title
...
...
@@ -155,3 +157,4 @@ class TestProjectsParser(TestCase):
with
open
(
'projects.json'
,
'w'
)
as
outfile
:
json
.
dump
(
projects_list
,
outfile
,
indent
=
4
)
# print(json.dumps(projects_list, indent=4))
print
(
'Number of defined Projects {}
\n
'
.
format
(
count
))
tests/importxls/test_utils.py
View file @
dc7c3cb8
...
...
@@ -52,7 +52,7 @@ def collect_prj_info(sheets_folder):
sheet
=
book
.
sheet_by_name
(
'projects'
)
prj_acronyms
=
sheet
.
column
[
1
]
numprojects
=
len
(
prj_acronyms
)
-
2
print
(
'{}---> {} ----> {}'
.
format
(
fname
,
len
(
prj_acronyms
),
prj_acronyms
))
if
numprojects
>
0
:
for
row
in
range
(
2
,
2
+
numprojects
):
projects
.
append
((
sheet
[
row
,
1
],
full_file_path
,
sheet
[
row
,
2
],
sheet
[
row
,
3
],
sheet
[
row
,
4
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment