-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo33.cs
57 lines (52 loc) · 1.81 KB
/
algo33.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
namespace HelloWorld
{
class Program
{
public class Algorithm
{
public static string MakeComplement(string dna)
{
char[] DnaChar = dna.ToCharArray();
char[] result = new char[DnaChar.Length];
for (int i = 0; i < DnaChar.Length; i++)
{
switch (DnaChar[i])
{
case 'A': result[i] = 'T'; break;
case 'T': result[i] = 'A'; break;
case 'C': result[i] = 'G'; break;
case 'G': result[i] = 'C'; break;
}
}
return new string(result);
}
public static string MakeComplement2(string dna)
{
// DNA bazlarının tamamlayıcılarını bir sözlükte depola
var complements = new Dictionary<char, char>
{
{'A', 'T'},
{'T', 'A'},
{'C', 'G'},
{'G', 'C'}
};
// LINQ kullanarak DNA dizisinin tamamlayıcısını oluştur
return new string(dna.Select(c => complements[c]).ToArray());
}
}
static void Main(string[] args)
{
string x = "ATTGC";
Console.WriteLine(Algorithm.MakeComplement(x));
string y = "ATTGC";
Console.WriteLine(Algorithm.MakeComplement2(y));
}
}
}