Exemple #1
0
 def create_or_update(self, key, value):
     record = Record(key, value, type(value))
     if self.pipe:
         self.in_memory_db[key] = record
     else:
         file_path = self.dbcore.get_file_path(key)
         self.dbcore.write(file_path, record)
     return record
 def test_read_write(self):
     key = str(uuid.uuid4())
     value = "test"
     dbcore = DbCore()
     record = Record(key, value, type(value))
     folder_path = dbcore.get_file_path(key)
     dbcore.write(folder_path, record)
     assert dbcore.read(folder_path).value == value
     dbcore.delete(folder_path)
 def test_delete(self):
     key = str(uuid.uuid4())
     value = "test"
     dbcore = DbCore()
     record = Record(key, value, type(value))
     folder_path = dbcore.get_file_path(key)
     dbcore.write(folder_path, record)
     dbcore.delete(folder_path)
     try:
         dbcore.read(folder_path)
     except FileNotFoundError:
         assert True
Exemple #4
0
    def run(self):
        if options.args['logfile']:
            logging.info('Process ' + str(self.threadidx) +
                         ' - variant annotation started.')

        # Iterating through input file
        counter = 0
        thr = 10
        for line in self.infile:
            counter += 1

            # Considering lines between startline and endline only
            if counter < int(self.startline): continue
            if not self.endline == '':
                if counter > int(self.endline): break

            line = line.strip()
            if line == '': continue

            # Printing out progress information
            if not copts.stdout and self.threadidx == 1:
                if counter % 1000 == 0:
                    printProgressInfo(
                        counter, int(self.numOfRecords / self.copts.threads))

            # Parsing record from input file
            record = Record(line, self.options, self.targetBED)

            # Filtering out REFCALL records
            if record.filter == 'REFCALL': continue

            # Filtering record, if required
            if self.options.args['filter'] and not record.filter == 'PASS':
                continue

            # Only include records of allowed chromosome names
            if record.chrom not in self.chroms: continue

            # Annotating the record based on the Ensembl, dbSNP and reference data
            record.annotate(self.ensembl, self.dbsnp, self.reference,
                            self.impactdir)

            # Writing annotated record to output file
            record.output(self.options.args['outputformat'], self.outfile,
                          self.options, self.genelist, self.transcriptlist,
                          self.snplist, self.copts.stdout)

            # Writing progress information to log file
            if self.threadidx == 1 and self.options.args['logfile']:
                x = round(
                    100 * counter /
                    int(self.numOfRecords / self.copts.threads), 1)
                x = min(x, 100.0)
                if x > thr:
                    logging.info(str(thr) + '% of records annotated.')
                    thr += 10

        # Closing output file
        self.outfile.close()

        # Finalizing progreaa info
        if not copts.stdout and self.threadidx == 1: finalizeProgressInfo()