Commit b69bdbc2 authored by Ivan Vanát's avatar Ivan Vanát
Browse files

cleanup after solo_ltr and trf; correct solo_ltr numbering

parent b3de6c8e
Loading
Loading
Loading
Loading
+13 −1
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ class SoloLtrs(object):
    
    
    def create_ltr_multifasta(self, tes, seq):
    def create_ltr_multifasta(self, tes, seq):
        offset = len(self.ltr_lengths.keys())
        offset = len(self.ltr_lengths.keys())
        num = 1
        with open("{}_ltrs.fa".format(self.seqId), 'a+') as file:
        with open("{}_ltrs.fa".format(self.seqId), 'a+') as file:
            for i in range(len(self.ltr_lengths.keys()), len(self.ltr_lengths.keys()) + len(tes)):
            for i in range(len(self.ltr_lengths.keys()), len(self.ltr_lengths.keys()) + len(tes)):
                if (intervals.length(tes[i - offset].ltr_left_location) < 100
                if (intervals.length(tes[i - offset].ltr_left_location) < 100
@@ -48,9 +49,10 @@ class SoloLtrs(object):
                    or math.isnan(tes[i - offset].tsr_right[0])):
                    or math.isnan(tes[i - offset].tsr_right[0])):
                    continue
                    continue
                
                
                file.write(">ltr_" + str(i) + "\n") 
                file.write(">ltr_" + str(num) + "\n") 
                file.write(str(seq[tes[i - offset].ltr_left_location[0]:tes[i - offset].ltr_left_location[1] + 1]) + "\n")
                file.write(str(seq[tes[i - offset].ltr_left_location[0]:tes[i - offset].ltr_left_location[1] + 1]) + "\n")
                self.ltr_lengths["ltr_" + str(i)] = len(str(seq[tes[i - offset].ltr_left_location[0]:tes[i - offset].ltr_left_location[1] + 1]))
                self.ltr_lengths["ltr_" + str(i)] = len(str(seq[tes[i - offset].ltr_left_location[0]:tes[i - offset].ltr_left_location[1] + 1]))
                num += 1
    
    
    def run_blastn(self):
    def run_blastn(self):
        args = dict(config['blastx']['args'])
        args = dict(config['blastx']['args'])
@@ -114,6 +116,7 @@ class SoloLtrs(object):
        result.difference(intersections.keys())
        result.difference(intersections.keys())
        result.add(real_best)
        result.add(real_best)


    # refactor this
    def cleanup(self):
    def cleanup(self):
        if os.path.isfile("{}.nhr".format(self.ltrs_fasta_path)):
        if os.path.isfile("{}.nhr".format(self.ltrs_fasta_path)):
            os.remove("{}.nhr".format(self.ltrs_fasta_path))
            os.remove("{}.nhr".format(self.ltrs_fasta_path))
@@ -121,4 +124,13 @@ class SoloLtrs(object):
            os.remove("{}.nin".format(self.ltrs_fasta_path))
            os.remove("{}.nin".format(self.ltrs_fasta_path))
        if os.path.isfile("{}.nsq".format(self.ltrs_fasta_path)):
        if os.path.isfile("{}.nsq".format(self.ltrs_fasta_path)):
            os.remove("{}.nsq".format(self.ltrs_fasta_path))
            os.remove("{}.nsq".format(self.ltrs_fasta_path))
        if os.path.isfile("{}.ndb".format(self.ltrs_fasta_path)):
            os.remove("{}.ndb".format(self.ltrs_fasta_path))
        if os.path.isfile("{}.not".format(self.ltrs_fasta_path)):
            os.remove("{}.not".format(self.ltrs_fasta_path))
        if os.path.isfile("{}.ntf".format(self.ltrs_fasta_path)):
            os.remove("{}.ntf".format(self.ltrs_fasta_path))
        if os.path.isfile("{}.nto".format(self.ltrs_fasta_path)):
            os.remove("{}.nto".format(self.ltrs_fasta_path))
        
            
            
+9 −0
Original line number Original line Diff line number Diff line
@@ -74,6 +74,9 @@ def get_candidates(seqid):
            split = entry.split(' ')
            split = entry.split(' ')
            candidates.append(TandemRepeat([int(split[0]), int(split[1])], int(split[2]), float(split[3]),
            candidates.append(TandemRepeat([int(split[0]), int(split[1])], int(split[2]), float(split[3]),
                    int(split[5]), int(split[6]), int(split[7]), float(split[12]), split[-1]))
                    int(split[5]), int(split[6]), int(split[7]), float(split[12]), split[-1]))

    cleanup()
    
    return candidates
    return candidates


def filter_candidates(candidates):
def filter_candidates(candidates):
@@ -101,5 +104,11 @@ def filter_candidates(candidates):
            repeats.append(candidate)
            repeats.append(candidate)
    return repeats
    return repeats


def cleanup():
    if os.path.isfile("{}.fa.2.5.7.80.10.50.2000.dat".format(seqid)):
        os.remove("{}.fa.2.5.7.80.10.50.2000.dat".format(seqid))
    if os.path.isfile("{}.fa.2.5.7.80.10.50.2000.mask".format(seqid)):
        os.remove("{}.fa.2.5.7.80.10.50.2000.mask".format(seqid))