public string GetMpileupChromosomes() { if (ChromosomeNames != null && ChromosomeNames.Count > 0) { return(ChromosomeNames.Merge(",")); } return(null); }
public override bool PrepareOptions() { if (!PrepareOutputDirectory()) { return(false); } if (!string.IsNullOrWhiteSpace(ExcludeBedFile) && !File.Exists(ExcludeBedFile)) { ParsingErrors.Add("Exclude file not exists:" + ExcludeBedFile); return(false); } switch (From) { case DataSourceType.Mpileup: if (null == MpileupFile) { ParsingErrors.Add("Mpileup file not defined."); return(false); } if (!File.Exists(MpileupFile)) { ParsingErrors.Add(string.Format("Mpileup file not exists {0}.", MpileupFile)); return(false); } Console.WriteLine("#mpileup file: " + MpileupFile); break; case DataSourceType.BAM: if (null == NormalBam) { ParsingErrors.Add("Bam file for normal sample not defined."); } else if (!File.Exists(NormalBam)) { ParsingErrors.Add(string.Format("Bam file for normal sample not exists {0}", NormalBam)); } if (null == TumorBam) { ParsingErrors.Add("Bam file for tumor sample not defined."); } else if (!File.Exists(TumorBam)) { ParsingErrors.Add(string.Format("Bam file for tumor sample is not exists {0}", TumorBam)); } if (ThreadCount >= 2) { Console.WriteLine("Checking chromosome names for thread mode ..."); if (ChromosomeNames == null || ChromosomeNames.Count == 0 && File.Exists(GenomeFastaFile)) { var fai = GenomeFastaFile + ".fai"; if (File.Exists(fai)) { var lines = File.ReadAllLines(fai); ChromosomeNames = lines.ToList().ConvertAll(m => { var pos = m.IndexOfAny(new[] { '\t', ' ' }); if (pos == -1) { return(m); } return(m.Substring(0, pos)); }); } else { Console.WriteLine("Reading chromosome names from fasta file ..."); ChromosomeNames = SequenceUtils.ReadFastaNames(GenomeFastaFile); if (ChromosomeNames.Count == 0) { ParsingErrors.Add(string.Format("Genome fasta file doesn't contain chromosome names, {0}.", GenomeFastaFile)); return(false); } } foreach (var chr in ChromosomeNames) { Console.WriteLine(chr); } } } else { if (ChromosomeNames != null && ChromosomeNames.Count > 0) { Console.WriteLine("#mpileup chromosome names: " + ChromosomeNames.Merge(",")); } } break; case DataSourceType.Console: Console.WriteLine("#mpileup from console."); break; } return(true); }