Reverse complement from a file

The task is: Write a script (call it what you want) that that can analyze a fastafile (MySequences.fasta) by finding the reverse complement of the sequences. Using python. from itertools import repeat #opening file filename = "MySequences.fasta" file = open(filename, ‘r’) #reading the file for line in file: line = line.strip() if ">" in line:… Read More Reverse complement from a file

Removing characters from a list of strings if they don't follow a list

I have a python code and I’m working with a list of sequences seq0,seq1,seq2,seq3,seq4,seq5 = ‘CCACGCGTCCGCCGCGACCTGCGTTTTCCTGGGGGTCCGCAACTCTGGCTTGACCCAAGGACCCGGCCAC’,’attgccattatataACCCGGCCACCCCCATAGGCAGATGTCAGGACAACTCGCATCTCAGCAGAGCAGCCCCTGGCCCAGG’,’TCXCACCCATAGGCAGATGGCCTCCGCCCCACCCCCGGGAGGATTTCTTAATGGGGTGAAAATGC’,’CAGTCCCCGAAGCCAGGGTTCCGGGACCCCCGGGGCCGAGCTGGGCGCGGGAAAAGAAttacggacttaGTCAGCCCCGCAGGGG’,’ATGGGGTGATCGTCGCTCGCGGGCTCTGTCTTCCTGTTCACCCTCCTCTGCCCCCAACTCCATCTCTGAGACCTCCTGCCCCCCCA’,’AAAAAAGAAGTCGCTCGCGTCGCTCGCGGGCTGGGCTCTGTCTGCGTCGCTCGCGGGCTAGAGAGCCAGGGTGA’ NTs = [seq0,seq1,seq2,seq3,seq4,seq5] nucleotides = [‘G’,’A’,’C’,’T’, ‘U’] if any(x not in nucleotides for x in NTs): print("ERROR: non-nucleotide characters present") so this works so far and it does tell me if there are non-nucleotide characters present, but I also… Read More Removing characters from a list of strings if they don't follow a list

Creating a list of positions of a substring within a string (DNA) (Python 3)

I am doing a bioinformatics course and I am trying to write a function to find all occurrences of a substring within a string. def find_match(s, t): """Returns a list of all positions of a substring t in string s. Takes two arguments: s & t. """ occurrences = [] for i in range(len(s)-len(t)+1): #… Read More Creating a list of positions of a substring within a string (DNA) (Python 3)

Counting Pattern Per Column From Line X to Y Using AWK

I have a file that looks like this: Sample_ID Population CP026243.1_309 CP026243.1_318 CP026243.1_427 CP026243.1_449 CP026243.1_515 Turbot-BalticSea_01 BalticSea 0 0 0 Turbot-BalticSea_02 BalticSea -1 -1 -1 Turbot-BalticSea_03 BalticSea -1 -1 0 Turbot-BalticSea_04 BalticSea 0 0 -1 Turbot-BalticSea_05 BalticSea -1 -1 0 Turbot-BalticSea_06 BalticSea -1 0 0 Turbot-BalticSea_07 BalticSea -1 -1 -1 Turbot-BalticSea_08 BalticSea 0 0 0… Read More Counting Pattern Per Column From Line X to Y Using AWK