Example #1
0
    def onSearch(self, query):
        self.should_stop = False
        self.found_something = False

        # Transform whitespace-separated query into OR-regex.
        regex = re.compile(
            '|'.join(tools.get_pattern(word) for word in query.split()),
            re.IGNORECASE)

        for dir in self.get_search_paths() + [consts.dirBaseUsr]:
            # Check if search has been aborted during filtering
            if self.should_stop:
                break

            # Only search in home folder if we haven't found anything yet.
            if dir == consts.dirBaseUsr and self.found_something:
                break

            results = self.search_dir(dir, query)

            # Check if search has been aborted during searching
            if results is None or self.should_stop:
                break

            dirs, files = self.filter_results(results, dir, regex)
            if not self.should_stop and (dirs or files):
                self.found_something = True
                modules.postMsg(consts.MSG_EVT_SEARCH_APPEND, {
                    'results': (dirs, files),
                    'query': query
                })

        modules.postMsg(consts.MSG_EVT_SEARCH_END)
Example #2
0
    def onSearch(self, query):
        self.should_stop = False
        self.found_something = False

        # Transform whitespace-separated query into OR-regex.
        regex = re.compile('|'.join(tools.get_pattern(word)
                           for word in query.split()), re.IGNORECASE)

        for dir in self.get_search_paths() + [consts.dirBaseUsr]:
            # Check if search has been aborted during filtering
            if self.should_stop:
                break

            # Only search in home folder if we haven't found anything yet.
            if dir == consts.dirBaseUsr and self.found_something:
                break

            results = self.search_dir(dir, query)

            # Check if search has been aborted during searching
            if results is None or self.should_stop:
                break

            dirs, files = self.filter_results(results, dir, regex)
            if not self.should_stop and (dirs or files):
                self.found_something = True
                modules.postMsg(consts.MSG_EVT_SEARCH_APPEND,
                                {'results': (dirs, files), 'query': query})

        modules.postMsg(consts.MSG_EVT_SEARCH_END)
Example #3
0
def ss_motif(args):

    # sanity checks
    files = args.files
    print "# Finding 3D Single Strand Motifs..."
    # assert args.bulges < 3, "# FATAL: cannot do bulges > 2"
    ref_pdb = reader.Pdb(args.reference, res_mode=args.res_mode)
    ref_len = len(ref_pdb.model.sequence)
    ref_mat = (ref_pdb.model.get_gmat(args.cutoff)).reshape(-1)
    if args.seq == None:
        query = "N" * ref_len
    else:
        assert len(args.seq) == ref_len, "# FATAL: query structure and sequence length mismatch!"
        query = args.seq

    pattern = tools.get_pattern(query)
    # OK...
    fh = open(args.name, "w")
    fh.write("# This is a baRNAba run.\n")
    for k in sorted(args.__dict__):
        s = "# " + str(k) + " " + str(args.__dict__[k]) + "\n"
        fh.write(s)

    for i in xrange(0, len(files)):

        cur_pdb = reader.Pdb(files[i], res_mode=args.res_mode)
        cur_pdb.set_xtc(args.xtc)
        cur_len = len(cur_pdb.model.sequence)

        if cur_len < ref_len:
            continue

        # return indeces matching query
        indeces = tools.get_idx(cur_pdb.model.sequence, query, args.bulges)
        idx = 0
        while idx >= 0:
            gmats = [(cur_pdb.model.get_gmat(args.cutoff, index)).reshape(-1) for index in indeces]
            dists = distance.cdist([ref_mat], gmats) / np.sqrt(ref_len)

            below_t = (dists < args.treshold).nonzero()[1]
            for ss in below_t:
                seq = "_".join([cur_pdb.model.sequence_id[p] for p in indeces[ss]])
                string = "%8.5f %s %i - %s \n" % (dists[0, ss], files[i], idx, seq)
                fh.write(string)

            idx = cur_pdb.read()

    fh.close()