Ejemplo n.º 1
0
 static PhasedGenomeFile SimplePhase(string filename, GenomeFile gfile, SnpCollection refSnps) {
     Console.Write("Creating simple phased genome...");
     PhasedGenome phased = new PhasedGenome(gfile.Genome);
     Console.WriteLine("completed");
     PhasedGenomeFile pfile = new PhasedGenomeFile(GetPhasedFilename(filename));
     pfile.SetStandardComments();
     pfile.AddComment("## history");
     pfile.AddComment("## " + DateTime.Now.ToString() + " SimplePhase of " + phased.Count.ToString("#,##0") 
         + " homozygous SNPs (of " + gfile.Genome.Count.ToString("#,##0") + " total).");
     pfile.PhasedGenome = phased;
     return pfile;
 }
Ejemplo n.º 2
0
 public static void WritePhasedGenome(PhasedGenomeFile genomeFile) {
     genomeFile.Extension = "txt";
     Console.Write("Writing phased genome " + genomeFile.Name + "...");
     genomeFile.Write(true, new System.Threading.CancellationToken(), null);
     Console.WriteLine("completed");
 }
Ejemplo n.º 3
0
 public static void AddHistory(PhasedGenomeFile pfile, GenomeFile gfile, int count, IList<Tuple<SegmentMatch, SegmentMatch>> segs) {
     DateTime now = DateTime.Now;
     pfile.AddComment("## " + DateTime.Now.ToString() + " MatchPhase added " + count.ToString("#,##0") + " phased heterozygous SNPs using " + gfile.Name + ".");
     if ((segs != null) && (segs.Count > 0)) {
         string filename = Path.Combine(Path.GetDirectoryName(pfile.Filename), pfile.Name + "HISTORY.csv");
         List<string> lines = new List<string>();
         if (!File.Exists(filename)) {
             lines.Add("date,time,source,chromosome,origStart,origEnd,origLen(cM),sides,usedStart,usedEnd,usedLen(cM),newlyPhasedCount");
         }
         foreach (var tup in segs) {
             var match = tup.Item1;
             var phased = tup.Item2;
             string line = "\"" + now.ToShortDateString() + "\",\"" + now.ToShortTimeString() + "\",\"" + gfile.Name + "\","
                 + Snp.ChromosomeToString(match.StartSnp.Chromosome) + "," + match.StartSnp.Position.ToString() + ","
                 + match.EndSnp.Position.ToString() + "," + match.CmLength.ToString("#0.00") + "," 
                 + match.MatchKind.ToString() + "," + phased.StartSnp.Position.ToString() + "," 
                 + phased.EndSnp.Position.ToString() + "," + phased.CmLength.ToString("#0.00") + "," 
                 + phased.PhasedSnpCount.ToString();
             lines.Add(line);
         }
         File.AppendAllLines(filename, lines);
     }
 }
Ejemplo n.º 4
0
 public static PhasedGenomeFile ReadPhasedGenome(SnpCollection refSnps, string filename) {
     string phasedFilename = GetPhasedFilename(filename);
     if (!File.Exists(phasedFilename)) return null;
     PhasedGenomeFile result = new PhasedGenomeFile(phasedFilename);
     result.PhasedGenome = new PhasedGenome(1, 23);
     Console.Write("Reading phased genome " + result.Name + "...");
     result.Read(refSnps, new System.Threading.CancellationToken(), null);
     Console.WriteLine("completed");
     return result;
 }