Bioinformatics
-
Independent AllelesBioinformatics/Rosalind 2019. 6. 8. 15:04
http://rosalind.info/problems/lia/ from itertools import combinations from functools import reduce from math import factorial with open('rosalind_lia.txt') as f: data= list(map(lambda x: int(x), f.read().strip().split(' '))) def combi(n, r): return int(factorial(n) / factorial(r) / factorial(n - r)) AaBb_prob= 0.25 total = 2 ** data[0] # result = reduce(lambda a, b: a+b, map(lambda x: len(list(c..
-
Qualification Round. Problem 3 Introns DetectionBioinformatics/Bioinformatics Contest 2017 2019. 4. 4. 23:30
DNA원본과 splicing후 조각들의 read로 exon을 재조합하는 문제이다. exon1 - intron1 - exon2 - intron2 - exon3 - intron3 이고 exon1 - exon2 exon2 - exon3 이런식으로 주어지면 exon1 - exon2 - exon3을 구하면 되는것이다. 간단하게 말하자면 원본 DNA seq에서 임의의 seq를 제거해 주어진 exon들을 모두 포함하는 새로운 sequence를 만들면 된다. 가장 단순하게 생각해보면 DNA seq에서 모든 base들을 하나씩 포함하거나 제외하면서 만든 seq가 exon들을 전부 포함하는지 보면 된다. base별로 포함/미포함 조합을 가지고 있으므로 길이 l인 sequence의 모든 조합만 구하는것만으로도 2^l의 복잡..
-
Qualification Round. Problem 2 The Secondary Structure of RNABioinformatics/Bioinformatics Contest 2017 2019. 3. 28. 22:18
RNA sequence를 주고 해당 rna의 모든 염기들이 쌍을 이루는 secondary structure를 형성할수있는지를 묻는 문제이다. 괄호문제랑 사실상 똑같다. Stack에 염기를 하나씩 넣으면서 넣기직전에 stack의 제일 위에있는 염기와 넣을 염기가 쌍을 이루면 제일 위의 염기를 pop하면 된다. 아니면 push한다. from functools import reduce input = input() # with open('6') as f: # input = f.read().strip() combine = {'A': 'U', 'U': 'A', 'C': 'G', 'G': 'C'} pair_stack = [] for base in input: if len(pair_stack) == 0: pair_st..
-
Qualification Round. Problem 1 Chemical ReactionsBioinformatics/Bioinformatics Contest 2017 2019. 3. 23. 23:41
화학 반응식과 초기 substrate로 최종적으로 생성되는 물질들을 구하는 문제이다. from functools import reduce import sys input = [] for line in sys.stdin: input.append(line.strip()) # with open('2') as f: # input = f.read().strip().split('\n') chemicals = set(input[0].split(' ')) reactions = list(map(lambda reaction: list(map(lambda side: side.split('+'), reaction.split('->'))), input[1:])) num_chemicals = len(chemicals) while ..
-
Locating Restriction SitesBioinformatics/Rosalind 2019. 3. 4. 22:58
Resctiction enzyme은 유전자 재조합에 핵심적인 기술중 하나이다. restriction enzyme을 이용할 수 있는 restriction site를 찾는 문제이다. 문제에선 길이가 4-12인 restriction site들을 찾으라고 되어있다. restriction site는 upstream과 downstream이 일정 지점을 경계로 대칭으로 놓여있어야 하므로 결국 길이는 2n이어야 한다. 그러므로 4, 6, 8, 10, 12가 된다. from util.read import read_fasta data = read_fasta('rosalind_revp.txt')[0][1] def get_complement(seq): return ''.join(map(lambda base: 'T' if ba..
-
RNA SplicingBioinformatics/Rosalind 2019. 3. 3. 21:34
주어진 dna sequence에서 intron을 제거하고 exon만 남겨서 protein sequence를 구하는 문제이다. 단순하게 dna sequence에서 intron만 제거후 transcript하면 끝이다. from util.read import read_fasta from util.func_tools import DNA_CODON_TABLE from functools import reduce from textwrap import wrap fasta = read_fasta('rosalind_splc.txt') dna_seq = list(map(lambda x: x[1], fasta)) exon = reduce(lambda a,b: a[0:a.find(b)]+a[a.find(b)+len(b):], ..
-
Bioinformatics 문제에 대해서Bioinformatics 2019. 3. 3. 00:15
이번 Bioinformatics Contest 2019에 출전하고나서 느낀점은 기존의 알고리즘문제와는 다르다는것이다.기존의 알고리즘문제는 시간제한이 빡빡하다. 시간복잡도를 계산하여 생각해낸 알고리즘이 시간내에 정확한 답을 낼 수 있을지 고려해야한다. 대체로 O(n^2)이상이면 다른 알고리즘을 고려해야한다.하지만 Bioinformatics문제는 그렇지 않다. '현실적인 시간'내에 '납득할 만한'답을 내는 알고리즘을 만들어내는것이 중요하다. Bioinformatics는 다루는 데이터가 매우 큰 경우가 많다. 매우 복잡하고 n이 큰 np문제인 경우가 많으며 기존의 알고리즘으로는 도저히 1초안에 답이 안나오는 경우들도 많다. 결국 휴리스틱한 방법을 사용해야한다.그래서 Bioinformatics 분류의 문제들은 ..
-
Calculating Protein MassBioinformatics/Rosalind 2019. 3. 2. 23:50
단백질의 질량을 구하는 문제이다. 원래 아미노산이 펩타이드 결합을하면서 물이 빠져나가 단백질이되면 그것을 고려해줘야하지만 설명에서 we avoid the complication of having to distinguish between residues and non-residues by only considering peptides excised from the middle of the protein.이라고 되어있으므로 그냥 단순히 더하면 된다. from functools import reduce MASS_TABLE = {'A': 71.03711, 'C': 103.00919, 'D': 115.02694, 'E': 129.04259, 'F': 147.06841, 'G': 57.02146, 'H': 137...