58
58
usedExperimentIdentifiers = set ()
59
59
checksumMap = {}
60
60
61
+ # facilities that want us to remove certain log files
62
+ blacklistedByFacility = {"qeana03-imgagdna" : ["DutyTimeLog" , "FinalSummaryLog" , "ReportMdLog" , "ReportPDFLog" , "ThroughputLog" , "DriftCorrectionLog" , "MuxScanDataLog" ]}
63
+
61
64
def createNewSample (transaction , space , parentSampleCode ):
62
65
run = 0
63
66
sampleExists = True
@@ -100,15 +103,26 @@ def getTimeStamp():
100
103
ts = str (now .minute )+ str (now .second )+ str (now .microsecond )
101
104
return ts
102
105
106
+ def copyFileTo (file , filePath , targetFolderPath ):
107
+ sourcePath = os .path .join (filePath , file .getName ())
108
+ shutil .copy2 (sourcePath , targetFolderPath )
109
+ src = os .path .join (filePath , file .getName ())
110
+ shutil .copy2 (src , targetFolderPath )
111
+
103
112
# copies log files from a folder that may contain other files to another path
104
- def copyLogFilesTo (logFiles , filePath , targetFolderPath ):
113
+ # log files that are blacklisted are not copied and thus not registered (after metadata extraction)
114
+ def copyLogFilesTo (logFiles , filePath , targetFolderPath , facilityName ):
115
+ # return list of files to remove for this facility or empty list
116
+ blacklist = blacklistedByFacility .get (facilityName , [])
117
+ numIgnoredFiles = 0
105
118
for logFile in logFiles :
106
- sourcePath = os .path .join (filePath , logFile .getName ())
107
- shutil .copy2 (sourcePath , targetFolderPath )
108
- src = os .path .join (filePath , logFile .getName ())
109
- shutil .copy2 (src , targetFolderPath )
119
+ fileType = logFile .__class__ .__name__
120
+ if fileType in blacklist :
121
+ numIgnoredFiles += 1
122
+ else :
123
+ copyFileTo (logFile , filePath , targetFolderPath )
110
124
copiedContent = os .listdir (targetFolderPath )
111
- if len (copiedContent ) != len (logFiles ):
125
+ if len (copiedContent ) + numIgnoredFiles != len (logFiles ):
112
126
raise AssertionError ("Not all log files have been copied successfully to target log folder." )
113
127
114
128
def createLogFolder (targetPath ):
@@ -117,6 +131,9 @@ def createLogFolder(targetPath):
117
131
os .makedirs (newLogFolder )
118
132
return newLogFolder
119
133
134
+ def containsUnclassifiedData (unclassifiedMap ):
135
+ return not all (v is None for v in unclassifiedMap .values ())
136
+
120
137
def createExperimentFromMeasurement (transaction , currentPath , space , project , measurement , origin , rawDataPerSample ):
121
138
""" Register the experiment with samples in openBIS.
122
139
In order to register the Nanopore experiment with its measurements in openBIS,
@@ -162,10 +179,10 @@ def createExperimentFromMeasurement(transaction, currentPath, space, project, me
162
179
datamap = rawDataPerSample .get (barcode )
163
180
newLogFolder = createLogFolder (currentPath )
164
181
# 3.) Aggregate all log files into an own log folder per measurement
165
- copyLogFilesTo (measurement .getLogFiles (), currentPath , newLogFolder )
182
+ copyLogFilesTo (measurement .getLogFiles (), currentPath , newLogFolder , origin )
166
183
createSampleWithData (transaction , space , barcode , datamap , runExperiment , currentPath , newLogFolder )
167
184
unclassifiedMap = measurement .getUnclassifiedData ()
168
- if len (unclassifiedMap ) > 0 :
185
+ if containsUnclassifiedData (unclassifiedMap ):
169
186
registerUnclassifiedData (transaction , unclassifiedMap , runExperiment , currentPath , measurement .getFlowcellId ())
170
187
171
188
# fills the global dictionary containing all checksums for paths from the global checksum file
0 commit comments