Пример #1
0
 public DefaultParticipantFinder(IParticipantFinder finder, string defaultValue)
 {
   this.finder = finder;
   this.defaultValue = defaultValue;
 }
Пример #2
0
        public static Dictionary <string, List <BarInfo> > GetAllSampleMap(string dir, string[] filePatterns, IParticipantFinder finder)
        {
            DefaultParticipantFinder dfinder = new DefaultParticipantFinder(finder, string.Empty);

            var files = (from filepattern in filePatterns
                         from subdir in Directory.GetDirectories(dir)
                         from file in Directory.GetFiles(subdir, filepattern)
                         where !File.Exists(file + ".bad")
                         select file).GroupBy(m => Path.GetFileName(m)).ToList().ConvertAll(m => m.Last());

            var plist = (from file in files
                         let barcode = dfinder.FindParticipant(Path.GetFileName(file))
                                       where barcode != string.Empty
                                       orderby barcode
                                       select new BarInfo(barcode, file)).ToList();

            return(plist.GroupBy(m => m.BarCode).ToDictionary(m => m.Key, m => m.ToList()));
        }
Пример #3
0
        public static Dictionary <string, List <BarInfo> > GetSampleMap(string dir, string[] filePatterns, IParticipantFinder finder, bool paired)
        {
            DefaultParticipantFinder dfinder = new DefaultParticipantFinder(finder, string.Empty);

            var files = new HashSet <string>();

            foreach (var filepattern in filePatterns)
            {
                if (files.Count > 0)
                {
                    break;
                }

                //some file will be duplicated in multiple directory, so we need to keep only one such file
                files = new HashSet <string>((from subdir in Directory.GetDirectories(dir)
                                              from file in Directory.GetFiles(subdir, filepattern)
                                              where !File.Exists(file + ".bad")
                                              select file).GroupBy(m => Path.GetFileName(m)).ToList().ConvertAll(m => m.Last()));
            }

            var plist = (from file in files
                         let barcode = dfinder.FindParticipant(Path.GetFileName(file))
                                       where barcode != string.Empty
                                       orderby barcode
                                       select new BarInfo(barcode, file)).ToList();

            if (paired)
            {
                var pgroup = plist.GroupBy(m => m.Paticipant).ToList();

                var result = new Dictionary <string, List <BarInfo> >();
                foreach (var m in pgroup)
                {
                    if (m.Count() == 1)
                    {
                        continue;
                    }

                    if ((from mm in m select mm.BarCode).Distinct().Count() == 1)
                    {
                        continue;
                    }

                    var ml = m.ToList();
                    for (int i = 0; i < ml.Count; i++)
                    {
                        for (int j = i + 1; j < ml.Count; j++)
                        {
                            if (ml[j].Sample - ml[i].Sample == 10)
                            {
                                result[m.Key] = new List <BarInfo>(new[] { ml[i], ml[j] });
                                break;
                            }
                        }
                    }
                }
                return(result);
            }
            else
            {
                return(plist.GroupBy(m => m.BarCode).ToDictionary(m => m.Key, m => m.ToList()));
            }
        }
 public DefaultParticipantFinder(IParticipantFinder finder, string defaultValue)
 {
     this.finder       = finder;
     this.defaultValue = defaultValue;
 }