Commit dc7c3cb8 authored by Pinar Alper's avatar Pinar Alper
Browse files

Added counting

parent 6ed65759
......@@ -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))
......@@ -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))
......@@ -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
......@@ -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))
......@@ -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],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment