def funcIDNormPCL(target, source, env, iMaxLines=100000): strT, astrSs = sfle.ts(target, source) strS = astrSs[1] if ( len(sfle.readcomment(astrSs[1])) > c_iSkip) else astrSs[0] iLC = sfle.lc(strS) return (sfle.ex("Normalizer -t pcl -T medmult < " + strS, strT) if (iLC < iMaxLines) else sfle.ex("head -n 3 < " + strS, strT))
def funcMergeMap(target, source, env): strT, astrSs = sfle.ts(target, source) fileTaxa, fileMerge, fileIDRaw = astrSs[:3] astrTaxa = sfle.readcomment(fileTaxa) strMap = arepa.get_mappingfile(astrTaxa[0]) if astrTaxa else "" return (sfle.ex([fileMerge, fileIDRaw, strMap, strT]) if strMap else sfle.ex(["cp", fileIDRaw, strT]))
def funcRawProcess(target, source, env): strT, astrSs = sfle.ts(target, source) strIn, strRData, strExpMetadata, strCondMetadata = astrSs[:4] iRet = sfle.ex((sfle.cat(strIn), "| R --no-save", "--args", strRData, strT, c_strPPfun, strExpMetadata, strCondMetadata)) if iRet: iRet = sfle.ex((sfle.cat(strIn), " | R --no-save --args", c_strFilePCL, strT, c_strPPfun, strExpMetadata, strCondMetadata)) return iRet
def getGPL(target, source, env): astrTs, astrSs = ([f.get_abspath() for f in a] for a in (target, source)) strAnnot, strPlatform = astrTs[:2] strRMeta = astrSs[0] pid = [row for row in csv.DictReader(open(strRMeta))][0]["platform_id"] strGPLID = c_strID.split("-")[1] if len(c_strID.split("-")) == 2 else pid listGPL = [ v.replace(".annot.gz", "") for v in sfle.readcomment(c_fileAnnot) ] if strGPLID in listGPL: #Annotation file exist, download sfle.ex([ "wget", sfle.d(c_strURLGPL, strGPLID + ".annot.gz"), "-O", strAnnot ]) else: #Annotation file does not exist, skip download sfle.ex(["touch", strAnnot]) #Make platform file containing gpl identifier with open(strPlatform, "w") as outputf: outputf.write(strGPLID)
def _compileR( target, source, env ): strT, astrSs = sfle.ts( target, source ) sfle.ex( ["chmod", "755", strDirectory] ) sfle.ex( ["R", "CMD", "build", strDirectory] ) with open( strT, "w" ) as outputf: outputf.write( "R package compiled OK")
# Iteratively download temporary xml files #=========================================================================== def discrete_list(num, increment): iTries = (num / increment) + 1 return [str(1 + (a * increment)) for a in range(iTries)] count_list = discrete_list(int(id_count), c_iIncrement) astrOutput = [ sfle.d(sfle.c_strDirTmp, geo_id + str(i) + c_strSufXML) for i in range(1, len(count_list) + 1) ] query_list = list( zip(astrOutput, count_list, [query_key] * len(count_list), [web_env] * len(count_list))) # Download for astr in query_list: strT, strCount, strQuery, strWeb = astr sfle.ex([ "curl", "-g", "-f", "-z", '"' + strT + '"', '"' + c_strURLSum % (strCount, strQuery, strWeb) + '"', ">", strT ]) #Save with open(sfle.d(sfle.c_strDirTmp, geo_id + c_strSufXML), "w") as idXML: idXML.write("\n".join([open(f).read() for f in zip(*query_list)[0]]))
def funcRawMap(target, source, env): astrTs, astrSs = ([f.get_abspath() for f in a] for a in (target, source)) strOutputRData = astrTs[0] strIn, astrCel = astrSs[0], astrSs[1:] return sfle.ex([sfle.cat(strIn), " | R --no-save --args", strOutputRData] + astrCel)
def funcIDQUANT(target, source, env): strT, astrSs = sfle.ts(target, source) strS = astrSs[0] iLC = sfle.lc(strS) return (sfle.ex("echo '-1.5\t-0.5\t0.5\t1.5\t2.5\t3.5\t4.5' >" + strT))
def funcIDDAB(target, source, env): strT, astrSs = sfle.ts(target, source) strS = astrSs[0] iLC = sfle.lc(strS) return (sfle.ex((sfle.cat(strS), " | Distancer -o", strT)) if (iLC > 3) else sfle.ex("echo", strT))
def funcIDKNNPCL(target, source, env, iMaxLines=40000): strT, astrSs = sfle.ts(target, source) strS = astrSs[0] iLC = sfle.lc(strS) return (sfle.ex("KNNImputer < " + strS, strT) if (iLC < iMaxLines) else sfle.ex("head -n 3 < " + strS, strT))
def _funcDAB(target, source, env): strT, astrSs = sfle.ts(target, source) strOut, strMap = astrSs[:2] return sfle.ex(("Dat2Dab", "-o", strT, "-i", (strOut if sfle.isempty(strMap) else strMap)))