def print_dest(self): # XXX: Muss in rcmd, rsync und search_for_output verwendet werden! output = self.output print(colored(output, '\nDestination: ' + colored(output, self.name, attrs=['bold']), on_color='on_green'), file=output) self.print_dest = tunix
def diff(a, b, a_filename, out=stdout, diffpdf=tunix): def diff_bin(diff_bin_func): if a != b: if a: explanation = not_printable_diff_text diff_bin_func() else: explanation = make_explanation('is empty') out.write(filename_prepared_for_output + explanation) def diff_bin_tunix(): diff_bin(tunix) def diff_bin_pdf(): diff_bin(diffpdf) filename_prepared_for_output = colored(out, a_filename, on_color='on_yellow') {'pdf': diff_bin_pdf, 'PDF': diff_bin_pdf, 'war': diff_bin_tunix, 'so': diff_bin_tunix, }.get(splitext(a_filename)[1][1:], lambda: out.write(''.join(map(lambda x: x + '\n', unified_diff(a.splitlines(), # \r must be stripped from windows files: map(lambda x: x.rstrip('\r'), b.splitlines()), filename_prepared_for_output)) )) )()
def do_file_list(self, out=stdout): file_list_file_name = self.file_list_file_name() if exists(file_list_file_name): stored_file_list = file_content(file_list_file_name ).splitlines() else: stored_file_list = [] cease_to_be_managed = set(stored_file_list) - self.file_list if cease_to_be_managed: out.write(colored(out, 'These files cease to be managed by this system:', on_color='on_red') + '\n' + '\n'.join(sorted(cease_to_be_managed)) + '\n')
from dna_toolkit import * from utilities import colored import random random_dna = ''.join([random.choice(nucleotides) for nuc in range(50)]) dna_str = validate_seq(random_dna) print('Test: ', count_nuc_freq(dna_str)) print('Test:', reverse_complement(dna_str)) print('Sequence: {}\n'.format(colored(dna_str))) print('[1] + Sequence Length: {}\n'.format(len(dna_str))) print( colored('[2] + Nucleotide Frequence: {}\n'.format( count_nuc_freq(dna_str)))) print('[3] + DNA/RNA transcription: {}\n'.format(transcription(dna_str))) print('[4] + DNA string + reverse transcript:\n5\' {} 3\''.format( colored(dna_str))) print(' ' + ''.join('|' for i in range(len(dna_str)))) print( colored('3\' {} 5\' [Complement]\n'.format( reverse_complement(dna_str)[::-1]))) print( colored('3\' {} 5\' [Rev. Complement]\n'.format( reverse_complement(dna_str)))) print('[5] + GC content {}%\n'.format(gc_content(dna_str))) print('[6] + GC content in subseq k=5: {}\n'.format( gc_content_subsec(dna_str, k=5))) print('[7] + Aminoacids sequence from DNA: {}\n'.format( translate_seq(dna_str, 0))) print('[8] + Codon Frequencyof (L): {}\n'.format(codon_usage(dna_str, 'L')))
from DNAToolkit import * from utilities import colored import random randDNAStr = ''.join([random.choice(Nucleotidos) for nuc in range(50)]) DNAStr = validateSeq(randDNAStr) print(f'\nSequence: {colored(DNAStr)}\n') print(f'[1] + Sequence Lenght: {len(DNAStr)}\n') print(colored(f'[2] + Nucleotide Frecuency: {countNucFrequency(DNAStr)}\n')) print(f'[3] + DNA/RNA Transcription: {colored(transcription(DNAStr))}\n') print(f"[4] + DNA String + Reverse Complement:\n5' {colored(DNAStr)} 3' ") print(f" {''.join(['|' for c in range(len(DNAStr))])}") print(f"3' {colored(reverse_complement(DNAStr)[::-1])} 5'[Complement]") print(f"5' {colored(reverse_complement(DNAStr))} 3'[Rev.Complement]\n") print(f'[5] + GC Content: {gc_content(DNAStr)}%\n') print( f'[6] + GC Content in Subsection k = 5: {gc_content_subsec(DNAStr, k=5)}\n' ) print(f'[7] + Aminoacids Sequence from DNA: {translate_seq(DNAStr, 0)}\n') print(f'[8] + Codon Frecuency (L): {codon_usage(DNAStr, "L")}\n') print('[9] + Reading Frames: ') for frame in gen_reading_frames(DNAStr): print(frame)
from DNAToolkit import * from utilities import colored if __name__ == "__main__": randStr = createRandDNA(50) DNAStr = validateSeq(randStr) print(f"\nSequence: {colored(DNAStr)}") print(f"[1] + Sequence length: {len(DNAStr)}") print(colored(f"[2] + Nucleotide Frequency {countNucFrequency(DNAStr)}")) print(f"[3] + DNA/RNA Transcription: {colored(transcription(DNAStr))}") print(f"[4] + DNA String + Reverese Complemet:\n") print(f"3\' {colored(DNAStr)} 5\'") print(f" " + ''.join(['|' for _ in range(len(DNAStr))])) print(f"3\' {colored(reverseComplement(DNAStr))} 5\'\n")
def rcmd(self, cmd, output_catcher=None): print(colored(stdout, cmd, 'red'))
from DNA_toolkit import * import random from utilities import colored # Random_DNA = "aActgAGGTG" Random_Num = random.randint(1, 50) Random_DNA2 = ''.join([random.choice(Nucleotides) for i in range(Random_Num)]) # Nuc_Val(Random_DNA) a = Nuc_Val(Random_DNA2) print(colored(a) + "\n") c = Nuc_Freq(a) print(colored(f"{c}")) d = Transcription(a) e = RNA_Nuc_Freq(d) print(colored(f"{e}")) l = len(a) r = Reverse_Complement(a) print(colored(r)) g = gc_content(a) g_s = gc_content_subsec(a, k=5) #Conversion of dictionary to string to insert in the database as .txt a = str(a) c = str(c) d = str(d) e = str(e) l = str(l) r = str(r) g = str(g) g_s = str(g_s)
import dna_toolkit as dtlk import random from utilities import colored #test_seq = "ACGTTAGTGATGTG" rand_seq = ''.join([random.choice(dtlk.Nucleotides) for nuc in range(20) ]) # remember, list comprehension goes from right to left print(colored(dtlk.validate_seq(rand_seq.lower()))) print(f"[1] Sequence length {len(rand_seq)}\n") print( colored( f"[2] Nucloetide frequency {dtlk.count_nucleotide_freq(rand_seq)}\n")) print(f"[3] DNA->RNA Transcription {colored(dtlk.transcription(rand_seq))}\n") print(f"p[4] Reverse complement:\n5' {colored(rand_seq)} 3'") print(f" {''.join(['|' for c in range(len(rand_seq))]) } ") print(f"5' {colored(dtlk.reverse_complement(rand_seq))} 3' ") print(f"[6] GC Content {dtlk.gc_content(rand_seq)}") print(f"[7] GC Subsequence Content {dtlk.gc_content_subsec(rand_seq, 10)}") #print(f"[8] Aminoacids sequence from DNA {dtlk.translate_seq(rand_seq)}") print(dtlk.translate_seq("AAGGTCTC"))
from DNAToolkit import * from utilities import colored import random # Main testing file # Create random DNA sequence: randDNAStr = ''.join([random.choice(Nucleotides) for nuc in range(100)]) DNAStr = validate_seq(randDNAStr) print(f"\nSequence: {colored(DNAStr)}\n") print(f"[1] + Sequence Length: {len(DNAStr)}\n") print(colored(f'[2] + Nucleotide Frequency: {nucleotide_frequency(DNAStr)}\n')) print(f"[3] + DNA/RNA Transcription: {colored(transcription(DNAStr))}\n") print(f"[4] + DNA String + Complement:\n5' {colored(DNAStr)} 3' ") print(f" {''.join(['|' for c in range(len(DNAStr))])}") print(f"3' {colored(complement(DNAStr))} 5' [Complement]\n") print(f"5' {colored(reverse_complement(DNAStr))} 3' [Rev. Complement]\n") print(f"[5] + GC Content: {gc_content(DNAStr)}%\n") print( f"[6] + GC Content in Subsection k=5: {gc_content_subseq(DNAStr, k=5)}\n") print(f'[7] + Amino acids Sequence from DNA: {translate_seq(DNAStr, 0)}\n') print(f'[8] + Codon frequency (L): {codon_usage(DNAStr, "L")}\n') print(f'[9] + Reading frames:') for frame in gen_reading_frames(DNAStr):
from DNAToolkit import * from utilities import colored import random randomStr = ''.join([random.choice(Nucleotides) for nuc in range(50)]) DNAStr = validateSequence(randomStr) testDNAStr = "AThTCGT" print(f'\nSequence: {colored(DNAStr)}\n') print(f'[1] + Sequence Lenght: {len(DNAStr)}\n') print(colored(f'[2] + Nucleotide Frequency {countNucFrequency(DNAStr)}\n')) print(colored(f'[3] + DNA -> RNA Transcription {transcription(DNAStr)}\n')) print(colored(f"[4] + DNA String + Complement + Reverse Complement: \n5' {DNAStr} 3'")) print(f" {''.join(['|' for c in range(len(DNAStr))])}") print(colored(f"3' {reverse_complement(DNAStr)} 5'\n")) print(colored(f"5' {reverse_complement(DNAStr[::-1])} 3' [Rev Complement]")) print(colored(f"[5] + GC Content: {gc_content(DNAStr)}%\n")) print(f"[6] + GC Content in Subsection k=5: {gc_content_subsec(DNAStr, k=5)}\n") print(f"[7] + Aminoacids Sequence from DNA: {translate_seq(DNAStr, 0)}\n") print(f'[8] + Codon Frequency (L): {codon_usage(DNAStr, "L")}\n') print(f'[9] + Reading_frames:') for frame in gen_reading_frames(DNAStr): print(frame) test_rf_frame = ['L', 'M', 'T', 'A', 'L', 'V', 'V', 'L', 'S', 'R', 'R', 'G', 'S', '_', 'G', 'H'] print('\n[10] + All proteins in 6 open reading frames:') for prot in all_proteins_from_open_reading_frames(DNAStr, 0, 0, True): print(f'{prot}')