fix modulo expression.
[sgn.git] / bin / test / TrialComparisonFakeDataGen.py
blob47737b013e5d3be4a5bce1e7d63bebc384358fde
5 import csv, time,random, sys
6 cols = ['studyYear', 'studyDbId', 'studyName', 'studyDesign', 'locationDbId', 'locationName', 'germplasmDbId', 'germplasmName', 'germplasmSynonyms', 'observationLevel', 'observationUnitDbId', 'observationUnitName', 'replicate', 'blockNumber', 'plotNumber', 'Variable']
7 study_count = 5
8 accession_count = 50
9 value_range = (0,100)
10 value_wobble = 30
12 def make_row(study,accession,base_value):
13 studyYear = "2038"
14 studyDbId = str(study)
15 studyName = str(random.random()*1000000)#"Study"+str(study)
16 studyDesign = "chaos"
17 locationDbId = "00800"
18 locationName = "The Moon"
19 germplasmDbId = accession
20 germplasmName = "AN"+str(accession)
21 germplasmSynonyms = ''
22 observationLevel = "plot"
23 observationUnitDbId = "MoonPlanter"+str(accession)
24 observationUnitName = "MoonPlanter"+str(accession)
25 replicate = "1"
26 blockNumber = "1"
27 plotNumber = str(accession)
28 variable = str(max(0,base_value + random.randint(-value_wobble,value_wobble)))
29 return [studyYear,studyDbId,studyName,studyDesign,locationDbId,locationName,germplasmDbId,germplasmName,germplasmSynonyms,observationLevel,observationUnitDbId,observationUnitName,replicate,blockNumber,plotNumber,variable]
31 # with open("generated.csv","w") as outfile:
32 writer = csv.writer(sys.stdout,delimiter=',',quotechar='"',quoting=csv.QUOTE_ALL)
33 writer.writerow(cols)
34 row_list = []
35 for accession in range(accession_count):
36 base_value = random.randint(*value_range)
37 for study in range(study_count):
38 row_list.append(make_row(study,accession,base_value))
39 row_list.sort()
40 writer.writerows(row_list)