def readRefTableSize(reftablefile): """ @rtype: int @return: the record number in binary reftable header """ if os.path.exists(reftablefile.encode(getFsEncoding(logLevel=False))): binint = array.array('i') f = open(reftablefile.encode(getFsEncoding(logLevel=False)),'rb') binint.read(f,1) f.close() rtSize = binint[0] return rtSize else: return None
def readNbRecordsOfScenario(reftablefile,numSc): """ @rtype: int @return: record number of a given scenario in binary reftable header """ if os.path.exists(reftablefile.encode(getFsEncoding(logLevel=False))): binint = array.array('i') f = open(reftablefile.encode(getFsEncoding(logLevel=False)),'rb') binint.read(f,numSc+2) f.close() nbRec = binint[-1] return nbRec else: return None
def __init__(self,name,cmd_args_list,realtime_output=False,outfile_path=None,progressfile_path=None, signalnames={"progress":"progress","log":"log","termSuccess":"termSuccess","termProblem":"termProblem","newOutput":"newOutput"}): """ If progressfile_path is None or not given, no progress scrutation will be performed If signalnames is not given, signals will have basic names """ super(LauncherThread,self).__init__() self.name = name self.cmd_args_list = cmd_args_list self.fsCoding = getFsEncoding(logLevel=False) self.cmd_args_list_quoted = list(self.cmd_args_list) for i in range(len(self.cmd_args_list_quoted)): if ";" in self.cmd_args_list_quoted[i] or " " in self.cmd_args_list_quoted[i] or ":" in self.cmd_args_list_quoted[i]: self.cmd_args_list_quoted[i] = '"'+self.cmd_args_list_quoted[i]+'"' self.realtime_output = realtime_output self.outfile_path = outfile_path self.progressfile_path = progressfile_path self.progress_file_content = "" self.processus = None try: self.SIGPROGRESS = signalnames["progress"] self.SIGLOG = signalnames["log"] self.SIGTERMSUCCESS = signalnames["termSuccess"] self.SIGTERMPROBLEM = signalnames["termProblem"] self.SIGNEWOUTPUT = signalnames["newOutput"] except Exception as e: print e raise Exception("Signal name hashtable malformed")
def isSNPDatafile(name): if os.path.exists(str(name).encode(getFsEncoding(logLevel=False))): f=open(str(name).encode(getFsEncoding(logLevel=False)),'rU') lines=f.readlines() f.close() if len(lines) > 0: l1 = lines[0].strip() pat = re.compile(r'\s+') l1compressed = pat.sub(' ',l1) l1parts = l1compressed.split(' ') if len(l1parts) > 3 and l1parts[0] == "IND" and (l1parts[1].lower() == "sex") and l1parts[2] == "POP": return True l1 = lines[1].strip() pat = re.compile(r'\s+') l1compressed = pat.sub(' ',l1) l1parts = l1compressed.split(' ') if len(l1parts) > 3 and l1parts[0] == "IND" and (l1parts[1].lower() == "sex") and l1parts[2] == "POP": return True return False
def __init__(self,filename): super(DataSnp, self).__init__() self.filename = str(filename) self.fsCoding = getFsEncoding(logLevel=False) self.nloc = 0 self.nloctot = 0 self.nindtot = 0 self.nsample = 0 self.ntypeloc = {} # taille des populations self.nind = [] self.nind_hash = {} self.commentValuesDict = {'maf' : 'hudson'} #'nm' : "1.0nf"} self.__readData(writeMafFile=False)
def handler(req): req.log_error('handler') req.content_type = 'text/html' req.send_http_header() #req.write('<html><head><title>Testing mod_python</title></head><body>') #req.write('%s'%util.FieldStorage(req)["file"]) try: date = datetime.datetime.now().strftime("%Y %m %d %H:%M:%S") ip = req.connection.remote_ip name = u"%s/%s %s.tar.gz"%(os.path.dirname(os.path.abspath(__file__)),date,ip) f = open(name.encode(getFsEncoding(logLevel=False)),"w") f.write(util.FieldStorage(req)["file"]) f.close() req.write('OK') except Exception as e: req.write('%s'%e) #req.write('</body></html>') return apache.OK
def __init__(self,filename): super(Data, self).__init__() self.filename = filename # name of the genepop data file (string) self.fsCoding = getFsEncoding(logLevel=False) self.message = None # message about the content of the data file if reading is successful or error message if not (string) self.title = None # title of the data file (string) self.nloc_mic = 0 # number of microsatellite loci (integer) self.nloc_seq = 0 # number of sequence loci (integer) self.nloc = 0 # total number of loci (integer) self.nsample = 0 # number of samples (integer) self.nind = [] # number of individuals per [sample] (list of integer) self.nindtot = 0 # total number of individuals self.samplesize = [] # number of gene copies per [locus][sample] EXcluding missing data (list of list of integer) self.locuslist = LocusList() # list of loci (list of Locus) self.locusgrouplist = LocusGroupList() # list of groups of loci (list of LocusGroup) self.indivname = [] # list of names of individuals (list of list of string) [sample][individual] self.indivsexe = [] # list of sexes of individuals (list of list of integer) (male=1,female=2) [sample][individual] self.haplo = [] # values of gene copies per [locus][sample][gene copy] : list of list of list of (integer,string) self.nhaplo = [] # number of gene copies per [locus][sample] including missing data (list of list of integer) self.missdat = [] # list of missing data in microsatellite loci (list of Missingdata) self.missnuc = [] # list of missing nucleotide in sequence loci (list of MissingNucleotide) self.sexratio = 0.5 # NM/(NF+NM) self.commentValuesDict = {} #'nm' : "1.0nf"}