private void AddAFile(string filepath) { if (SraCollection.Count == 0) { var theExtension = Path.GetExtension(filepath).ToLowerInvariant(); theExtension = theExtension == ".gz" ? Path.GetExtension(Path.GetFileNameWithoutExtension(filepath)).ToLowerInvariant() : theExtension; switch (theExtension) { case ".fastq": if (Path.GetFileName(filepath).Contains("_1") || Path.GetFileName(filepath).Contains("_2")) { RNASeqFastqDataGrid rnaSeqFastq = new RNASeqFastqDataGrid(filepath); RnaSeqFastqCollection.Add(rnaSeqFastq); UpdateOutputFolderTextbox(); break; } else { MessageBox.Show("FASTQ files must have *_1.fastq and *_2.fastq extensions.", "Run Workflows", MessageBoxButton.OK, MessageBoxImage.Information); return; } } } else { MessageBox.Show("User already added SRA number. Please only choose one input: 1) SRA accession 2) FASTQ files.", "Run Workflows", MessageBoxButton.OK, MessageBoxImage.Information); return; } }
private void AddAFile(string filepath) { var theExtension = Path.GetExtension(filepath).ToLowerInvariant(); string basepath = theExtension == ".gz" ? Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(filepath)) : Path.GetFileNameWithoutExtension(filepath); theExtension = theExtension == ".gz" ? Path.GetExtension(Path.GetFileNameWithoutExtension(filepath)).ToLowerInvariant() : theExtension; switch (theExtension) { case ".fastq": if (Path.GetFileName(basepath).EndsWith("_1") || Path.GetFileName(basepath).EndsWith("_2")) { bool isPairedEnd = Path.GetFileName(basepath).EndsWith("_2"); bool isUnpairedSecondMate = false; bool isDifferentFolder = false; foreach (var fq in RnaSeqFastqCollection) { bool hasMatePair = Path.GetFileName(fq.FileName.Substring(0, fq.FileName.Length - 2)) == Path.GetFileName(basepath.Substring(0, basepath.Length - 2)); if (hasMatePair) { fq.IsPairedEnd = true; } isPairedEnd = isPairedEnd || hasMatePair; isUnpairedSecondMate = isUnpairedSecondMate || hasMatePair; isDifferentFolder = isDifferentFolder || Path.GetDirectoryName(fq.FilePath) != Path.GetDirectoryName(filepath); } if (isDifferentFolder) { MessageBox.Show("All FASTQs must be located in the same analysis directory.", "Add FASTQ", MessageBoxButton.OK, MessageBoxImage.Warning); } else { RNASeqFastqDataGrid rnaSeqFastq = new RNASeqFastqDataGrid(filepath, isPairedEnd); RnaSeqFastqCollection.Add(rnaSeqFastq); UpdateOutputFolderTextbox(); } break; } else { MessageBox.Show("FASTQ files must have *_1.fastq and/or *_2.fastq extensions.\n\n" + "Single-end experiments must have unique filenames preceeding the *_1.fastq ending.\n\n" + "Paired-end experiments must have the same unique filename preceeding the *_1.fastq and *_2.fastq suffixes.", "Run Workflows", MessageBoxButton.OK, MessageBoxImage.Information); return; } } }