Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- namespace BioHelper
- {
- class Program
- {
- static List<(string, string)> ReadFasta(string fileName)
- {
- var fileLines = File.ReadAllLines(fileName);
- var output = new List<(string, string)>();
- string curContent = "";
- string curName = "";
- foreach (var line in fileLines)
- {
- if (line.Contains(">"))
- {
- if (curContent != "")
- {
- output.Add((curName, curContent));
- }
- curName = line;
- curContent = "";
- }
- else
- {
- curContent += line;
- }
- }
- return output;
- }
- static void Main(string[] args)
- {
- var proteins = ReadFasta("augustus.whole_downloaded.aa");
- var queries = ReadFasta("dna_associated_proteins.fasta");
- List<string> result = new List<string>();
- foreach(var protein in proteins)
- {
- if (queries.Any(x => protein.Item2.Contains(x.Item2)))
- {
- result.Add(protein.Item2);
- }
- }
- File.WriteAllLines("result.txt", result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement