예제 #1
0
        public static List <DetectabilityEntry> ReadFromDirectory(string dir)
        {
            List <string> peptides      = FileUtils.ReadFile(dir + "\\peppro.txt", true);
            List <string> detectability = FileUtils.ReadFile(dir + "\\detectabilityres.txt", true);
            List <string> positions     = FileUtils.ReadFile(dir + "\\positions.txt", true);

            var deList = new List <DetectabilityEntry>();

            for (int iPep = 0; iPep < peptides.Count; iPep++)
            {
                string   pep = peptides[iPep];
                string[] pp  = Regex.Split(pep, "\\s+");
                if (pp.Length < 2)
                {
                    throw new Exception("Wrong peptide/protein line : " + pep);
                }

                double d        = MyConvert.ToDouble(detectability[iPep].Trim());
                int    position = int.Parse(positions[iPep].Trim());

                var de = new DetectabilityEntry();
                de.Protein       = pp[1];
                de.Peptide       = pp[0];
                de.Detectability = d;
                de.Position      = position;
                deList.Add(de);
            }
            return(deList);
        }
        public void TestReadFromFile()
        {
            List <DetectabilityEntry> deList = DetectabilityEntry.ReadFromFile(TestContext.CurrentContext.TestDirectory + "/../../../data/IPI00206171.detectability");

            Assert.AreEqual(135, deList.Count);
            Assert.AreEqual("APHWTSASLTEAAAHPHSPEMK", deList[1].Peptide);
            Assert.AreEqual("IPI:IPI00206171.1|", deList[1].Protein);
            Assert.AreEqual(0.4483, deList[1].Detectability, 0.0001);
            Assert.AreEqual(10, deList[1].Position);
        }
예제 #3
0
        public IEnumerable <string> Process(string fastaFilename)
        {
            var fi = new FileInfo(fastaFilename).FullName;

            SystemUtils.Execute(this.predictorExeFilePath, "-F \"" + fi + "\"");

            DirectoryInfo             di     = new FileInfo(fastaFilename).Directory;
            List <DetectabilityEntry> deList = DetectabilityEntry.ReadFromDirectory(di.FullName);

            string detectabilityFilename = FileUtils.ChangeExtension(fastaFilename, "detectability");

            DetectabilityEntry.WriteToFile(detectabilityFilename, deList);
            DetectabilityEntry.DeleteFromDirectory(di.FullName);

            return(new[] { detectabilityFilename });
        }
예제 #4
0
        public static List <DetectabilityEntry> ReadFromFile(string filename)
        {
            var result = new List <DetectabilityEntry>();

            List <string> lines = FileUtils.ReadFile(filename, true);

            for (int i = 1; i < lines.Count; i++)
            {
                String[] parts = Regex.Split(lines[i], "\t");
                if (4 == parts.Length)
                {
                    var de = new DetectabilityEntry();
                    de.Protein       = parts[0];
                    de.Peptide       = parts[1];
                    de.Detectability = MyConvert.ToDouble(parts[2].Trim());
                    de.Position      = int.Parse(parts[3].Trim());
                    result.Add(de);
                }
            }

            return(result);
        }