コード例 #1
0
        public override void Setup()
        {
            base.Setup();

            _coverageMinerMock     = Fixture.Freeze <Mock <CoverageMiner> >();
            _coverageValidatorMock = Fixture.Freeze <Mock <CoverageValidator> >();
            _coverageMapperMock    = Fixture.Freeze <Mock <CoverageMapper> >();
            _coverageSenderMock    = Fixture.Freeze <Mock <CoverageSender> >();
            _responseMapperMock    = Fixture.Freeze <Mock <ResponseMapper> >();

            _sessionActivity = new SessionActivity();

            _coverages = new List <Coverage>
            {
                new Coverage {
                    Name = "Coverage 1"
                },
                new Coverage {
                    Name = "Coverage 2"
                }
            };

            _coverageModel1 = new CoverageModel();
            _coverageModel2 = new CoverageModel();

            _responseModel1 = new ResponseModel();
            _responseModel2 = new ResponseModel();

            _response1 = new Response();
            _response2 = new Response();

            _coverageProcessor = new CoverageProcessor(_coverageMinerMock.Object, _coverageValidatorMock.Object, _coverageMapperMock.Object, _coverageSenderMock.Object, _responseMapperMock.Object);
        }
        public override void Setup()
        {
            base.Setup();

            _coverageMinerMock     = Fixture.Freeze <Mock <CoverageMiner> >();
            _coverageValidatorMock = Fixture.Freeze <Mock <CoverageValidator> >();
            _coverageMapperMock    = Fixture.Freeze <Mock <CoverageMapper> >();
            _coverageSenderMock    = Fixture.Freeze <Mock <CoverageSender> >();
            _responseMapperMock    = Fixture.Freeze <Mock <ResponseMapper> >();

            _coverages = new List <Coverage>
            {
                new Coverage()
                {
                    CoverageName = "DK", PolicyId = 2
                }
            };

            _coverageModel = new CoverageModel();

            _responseModel = new ResponseModel
            {
                Successful = true
            };

            _response = new Response();

            _coverageProcessor = new CoverageProcessor(_coverageMinerMock.Object, _coverageValidatorMock.Object, _coverageMapperMock.Object, _coverageSenderMock.Object, _responseMapperMock.Object);
        }
コード例 #3
0
        public void Setup()
        {
            _coverageModel = new CoverageModel();
            _responseModel = new ResponseModel();

            _coverageReceiver = new CoverageReceiver();
        }
コード例 #4
0
        protected List <ModelPoint> InitializeModelPoints(CoverageModel model)
        {
            List <ModelPoint> modelPoints = new List <ModelPoint>();

            double[] mu = GetProjectedMeanCoverage(model.DiploidCoverage);
            // Refine our estimate of diploid MAF:
            //double diploidMAF = this.EstimateDiploidMAF(2, model.DiploidCoverage);

            /////////////////////////////////////////////
            // Update the parameters in each SegmentPloidy object, and construct corresponding SegmentInfo objects
            foreach (SegmentPloidy ploidy in _allPloidies)
            {
                ModelPoint point        = new ModelPoint();
                double     pureCoverage = mu[ploidy.CopyNumber];
                point.Coverage = pureCoverage;
                double pureMaf = ploidy.MinorAlleleFrequency;
                point.Maf = pureMaf;
                if (double.IsNaN(point.Maf))
                {
                    point.Maf = 0;
                }
                point.Ploidy = ploidy;
                modelPoints.Add(point);
                point.CopyNumber = ploidy.CopyNumber;
                ploidy.MixedMinorAlleleFrequency = point.Maf;
                ploidy.MixedCoverage             = point.Coverage;
            }

            return(modelPoints);
        }
コード例 #5
0
        public virtual ResponseModel Receive(CoverageModel coverageModel)
        {
            var responseModel = new ResponseModel
            {
                Successful = true,
                Message    = "The coverage was received"
            };

            return(responseModel);
        }
        public void Setup()
        {
            _coverageModel = new CoverageModel
            {
                NameOfCoverage = "SJ",
                PolicyId       = 5
            };

            _coverageReceiver = new CoverageReceiver();
        }
コード例 #7
0
 public ApiCoverageModel MapCoverageCommonModel(CoverageModel coverage)
 {
     return(new ApiCoverageModel()
     {
         ID = coverage.ID,
         CoverageType = coverage.CoverageType,
         conditions = coverage.Conditions,
         Includes = coverage.Includes
     });
 }
        public virtual ResponseModel Receive(CoverageModel coverageModel)
        {
            var responseModel = new ResponseModel
            {
                Message    = $"Coverage {coverageModel.NameOfCoverage} has been received",
                Successful = true
            };

            return(responseModel);
        }
コード例 #9
0
        public virtual CoverageModel Map(Coverage coverage)
        {
            CoverageModel coverageModel = new CoverageModel
            {
                Name     = coverage.Name,
                PolicyId = coverage.PolicyId
            };

            return(coverageModel);
        }
コード例 #10
0
        public override void Setup()
        {
            base.Setup();

            _coverageReceiverMock = Fixture.Freeze <Mock <CoverageReceiver> >();

            _coverageModel = new CoverageModel();
            _responseModel = new ResponseModel();

            _coverageSender = new CoverageSender(_coverageReceiverMock.Object);
        }
コード例 #11
0
        public HttpResponseMessage AddInsurance([FromBody] ApiInsuranceModel insurance)
        {
            //Mapping Api Models to Common Models
            APIModelMapper mapper = new APIModelMapper();

            InsuranceModel            selectedInsurance = mapper.MapInsuranceTypeModel(insurance.InsuranceType, insurance, insurance.SelectedInsurance);
            ClientModel               client            = mapper.MapClientModel(insurance.Client);
            PolicyCoverageDetailModel policyCoverage    = mapper.MapPolicyCoverageDetailModel(insurance.PolicyDetails);
            DocumentModel             document          = mapper.MapDocumentModel(insurance.Documents);
            CoverageModel             coverage          = mapper.MapCoverage(insurance.Coverage);

            if (_insuranceManager.Record(selectedInsurance, client, policyCoverage, document, coverage))
            {
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            return(new HttpResponseMessage(HttpStatusCode.BadRequest));
        }
コード例 #12
0
        /// <summary>
        /// Fit a Gaussian mixture model.
        /// Fix the means to the model MAF and Coverage and run the EM algorithm until convergence.
        /// Compute the empirical MAF and Coverage.
        /// Fix the means to the empirical MAF and Coverage and run the EM algorithm again until convergence.
        /// Always estimate the full covariance matrix?
        /// </summary>
        /// <param name="model"></param>
        /// <param name="segments"></param>
        /// <param name="debugPath"></param>
        /// <returns></returns>
        private double FitGaussians(CoverageModel model, List <SegmentInfo> segments, string debugPath = null)
        {
            List <ModelPoint> modelPoints = InitializeModelPoints(model);

            GaussianMixtureModel gmm = new GaussianMixtureModel(modelPoints, segments, this.MeanCoverage, this.CoverageWeightingFactor, 0);
            double likelihood        = gmm.Fit();

            if (debugPath != null)
            {
                // write Gaussian mixture model to debugPath
                using (FileStream stream = new FileStream(debugPath, FileMode.Create, FileAccess.Write))
                    using (StreamWriter writer = new StreamWriter(stream))
                    {
                        writer.WriteLine("CN\tMajor Chr #\tMAF\tCoverage\tOmega\tMu0\tMu1\tSigma00\tSigma01\tSigma10\tSigma11");
                        foreach (ModelPoint modelPoint in modelPoints)
                        {
                            writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}",
                                             modelPoint.Ploidy.CopyNumber, modelPoint.Ploidy.MajorChromosomeCount,
                                             modelPoint.Ploidy.MixedMinorAlleleFrequency, modelPoint.Ploidy.MixedCoverage,
                                             modelPoint.Ploidy.Omega, modelPoint.Ploidy.Mu[0], modelPoint.Ploidy.Mu[1],
                                             modelPoint.Ploidy.Sigma[0][0], modelPoint.Ploidy.Sigma[0][1],
                                             modelPoint.Ploidy.Sigma[1][0], modelPoint.Ploidy.Sigma[1][1]);
                        }

                        writer.WriteLine("");
                        writer.WriteLine("MAF\tCoverage\tPosterior Probabilities");
                        StringBuilder sb = new StringBuilder();
                        foreach (SegmentInfo segment in segments)
                        {
                            sb.Clear();
                            sb.AppendFormat("{0}\t{1}", segment.MAF, segment.Coverage);
                            foreach (ModelPoint modelPoint in modelPoints)
                            {
                                sb.AppendFormat("\t{0}", segment.PosteriorProbs[modelPoint]);
                            }
                            writer.WriteLine(sb.ToString());
                        }
                    }
            }

            return(likelihood);
        }
コード例 #13
0
        public ApiInsuranceModel Get(String insuranceId)
        {
            /* ApiInsuranceModel insurance = new ApiInsuranceModel
             * {
             *   //ID = (int)ID,
             *   //AgentID = 1,
             *   //ClientID = 1,
             *   //Joining_Date = new DateTime(2000, 02, 29),
             *   //End_Date = new DateTime(2017, 02, 29),
             *   //Total_Value = 1000000,
             * };
             *
             * return insurance;*/

            InsuranceModel            selectedInsurance = _insuranceManager.Find <InsuranceModel>(e => e.ID.Equals(insuranceId));
            ClientModel               clientModel       = _insuranceManager.Find <ClientModel>(e => e.ID.Equals(selectedInsurance.ID));
            DocumentModel             document          = _insuranceManager.Find <DocumentModel>(e => e.InsuranceID.Equals(selectedInsurance.ID));
            PolicyCoverageDetailModel pcd      = _insuranceManager.Find <PolicyCoverageDetailModel>(e => e.InsuranceID.Equals(selectedInsurance.ID));
            CoverageModel             coverage = _insuranceManager.Find <CoverageModel>(e => e.ID.Equals(pcd.CoverageID));

            CommonToApiModelMapper mapper = new CommonToApiModelMapper();
            ApiInsuranceModel      mapped = new ApiInsuranceModel();

            if (selectedInsurance.InsuranceType.Equals(InsuranceModel.InsuranceTypes.LIFE_INSURANCE))
            {
                LifeInsuranceModel    life = _insuranceManager.Find <LifeInsuranceModel>(e => e.ClientID.Equals(selectedInsurance.ClientID));
                ApiLifeInsuranceModel apiLifeInsuranceModel = mapper.MapLifeInsuranceCommonModel(life);
                mapped.SelectedInsurance = apiLifeInsuranceModel;
            }
            ApiClientModel               apiCLient   = mapper.MapClientCommonModel(clientModel);
            ApiDocumentModel             apiDoc      = mapper.MapDocumentCommonModel(document);
            ApiPolicyCoverageDetailModel apiPcd      = mapper.MapPolicyCoverageDetailCommonModel(pcd);
            ApiCoverageModel             apiCoverage = mapper.MapCoverageCommonModel(coverage);

            mapped.Client        = apiCLient;
            mapped.Coverage      = apiCoverage;
            mapped.Documents     = apiDoc;
            mapped.PolicyDetails = apiPcd;

            return(mapped);
        }
コード例 #14
0
        public CoverageModel Get(string insureeNumber)
        {
            CoverageModel response = null;
            DataTable     data;

            DataHelper helper = new DataHelper(Configuration);

            SqlParameter[] sqlParameters =
            {
                new SqlParameter("@InsureeNumber", insureeNumber),
            };

            try
            {
                data = helper.GetDataTable("uspAPIGetCoverage", sqlParameters, CommandType.StoredProcedure);
            }
            catch (SqlException)
            {
                throw;
            }
            catch (Exception)
            {
                throw new Exception();
            }

            if (data.Rows.Count > 0)
            {
                var firstRow          = data.Rows[0];
                var jsonString        = JsonConvert.SerializeObject(data);
                var coverage_products = JsonConvert.DeserializeObject <List <CoverageProduct> >(jsonString);

                response = new CoverageModel()
                {
                    OtherNames = firstRow["OtherNames"].ToString(), LastNames = firstRow["LastName"].ToString(), BirthDate = firstRow["DOB"].ToString(), CoverageProducts = coverage_products
                };
            }

            return(response);
        }
コード例 #15
0
ファイル: MonoCov.cs プロジェクト: sergeyt/monocov
        private static int handleExportHtml(MonoCovOptions opts,string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Error: Datafile name is required when using --export-html");
                return(1);
            }

            if (!Directory.Exists(opts.exportHtmlDir))
            {
                try {
                    Directory.CreateDirectory(opts.exportHtmlDir);
                }
                catch (Exception ex) {
                    Console.WriteLine("Error: Destination directory '" + opts.exportHtmlDir + "' does not exist and could not be created: " + ex);
                    return(1);
                }
            }

            CoverageModel model = new CoverageModel();

            model.ReadFromFile(args [0]);
            HtmlExporter exporter = new HtmlExporter();

            exporter.DestinationDir = opts.exportHtmlDir;
            exporter.StyleSheet     = opts.styleSheet;
            if (!opts.quiet)
            {
                exporter.Progress += new HtmlExporter.ProgressEventHandler(htmlProgressListener);
            }
            exporter.Export(model);
            if (!opts.quiet)
            {
                Console.WriteLine();
                Console.WriteLine("Done.");
            }
            return(0);
        }
コード例 #16
0
        //Business Logics for Life Insurance
        private bool RecordNewLifeInsurance(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage)
        {
            ValidateAddInsurance validation = new ValidateAddInsurance();
            bool isCorrectAge  = validation.ValidateForAge(client.Age);
            bool isClientAdded = _repository.Create(client);

            if (isClientAdded)
            {
                bool isInsuranceAdded = _repository.Create(insurance);
                if (isInsuranceAdded)
                {
                    bool isDocumentAdded = _repository.Create(document);
                    if (isDocumentAdded)
                    {
                        bool isCoverageAdded = _repository.Create(coverage);
                        if (isCoverageAdded)
                        {
                            bool isPolicyCoverageAdded = _repository.Create(policyCoverage);
                            if (isPolicyCoverageAdded)
                            {
                                return(_repository.Save());
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #17
0
ファイル: CoverageView.cs プロジェクト: sergeyt/monocov
        public CoverageView(string fileName, ProgressBar status)
        {
            store = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(object));
            tree  = new TreeView(store);

            CellRendererText renderer         = new CellRendererText();
            CellRendererText coverageRenderer = new CellRendererText();

            // LAME: Why is this property a float instead of a double ?
            renderer.Xalign = 0.5f;

            tree.AppendColumn("Classes", new CellRendererText(), "text", 0);
            tree.AppendColumn("Lines Hit", renderer, "text", 1);
            tree.AppendColumn("Lines Missed", renderer, "text", 2);
            tree.AppendColumn("Coverage", coverageRenderer, "text", 3);

            tree.GetColumn(0).Resizable = true;
            tree.GetColumn(1).Alignment = 0.0f;
            tree.GetColumn(1).Resizable = true;
            tree.GetColumn(2).Alignment = 0.0f;
            tree.GetColumn(2).Resizable = true;
            tree.GetColumn(3).Alignment = 0.0f;
            tree.GetColumn(3).Resizable = true;
            tree.GetColumn(3).SetCellDataFunc(coverageRenderer, new TreeCellDataFunc(RenderCoverage));

            tree.HeadersVisible = true;

            model = new CoverageModel();
            foreach (string filter in DEFAULT_FILTERS)
            {
                model.AddFilter(filter);
            }
            this.status     = status;
            model.Progress += Progress;
            model.ReadFromFile(fileName);

            TreeItem root = new TreeItem(store, null, model, "PROJECT");

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable();
            string[] sorted_names = new string [classes2.Count];
            classes2.Keys.CopyTo(sorted_names, 0);
            Array.Sort(sorted_names);
            Progress("Building tree", 0.95);
            foreach (string name in sorted_names)
            {
                ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

                if (klass.filtered)
                {
                    continue;
                }

                string   namespace2 = klass.name_space;
                TreeItem nsItem     = (TreeItem)namespaces [namespace2];
                if (nsItem == null)
                {
                    nsItem = new TreeItem(store, root, (CoverageItem)model.Namespaces [namespace2], namespace2);
                    //				nsItem.SetPixmap (0, namespaceOpenPixmap);
                    namespaces [namespace2] = nsItem;
                }

                if (nsItem.model.filtered)
                {
                    continue;
                }

                ClassItem classItem = new ClassItem(store, nsItem, klass, klass.name);

                if (klass.ChildCount != 0)
                {
                    TreeIter treeIter = store.AppendNode(classItem.iter);
                    store.SetValues(treeIter, "<loading>");
                }
            }

            tree.ExpandRow(store.GetPath(root.Iter), false);

            // it becomes very hard to navigate if everything is expanded
            //foreach (string ns in namespaces.Keys)
            //	tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false);

            tree.RowExpanded      += new RowExpandedHandler(OnRowExpanded);
            tree.RowCollapsed     += new RowCollapsedHandler(OnRowCollapsed);
            tree.ButtonPressEvent += new ButtonPressEventHandler(OnButtonPress);
            tree.Selection.Mode    = SelectionMode.Single;

            source_views = new Hashtable();
            window_maps  = new Hashtable();
            Progress("Done", 1.0);
            // LAME: Why doesn't widgets visible by default ???
            tree.Show();
        }
コード例 #18
0
        public int CallVariants(string variantFrequencyFile, string inFile, string outFile, string ploidyBedPath, string referenceFolder, string sampleName,
                                string truthDataPath)
        {
            if (!string.IsNullOrEmpty(truthDataPath))
            {
                this.CNOracle = new CopyNumberOracle();
                this.CNOracle.LoadKnownCN(truthDataPath);
            }

            this.Segments   = CanvasSegment.ReadSegments(inFile);
            this.TempFolder = Path.GetDirectoryName(inFile);
            if (this.Segments.Count == 0)
            {
                Console.WriteLine("CanvasDiploidCaller: No segments loaded; no CNV calls will be made.");
                CanvasSegment.WriteSegments(outFile, this.Segments, referenceFolder, sampleName, null, null);
                return(0);
            }
            PloidyInfo ploidy = null;

            if (!string.IsNullOrEmpty(ploidyBedPath))
            {
                ploidy = PloidyInfo.LoadPloidyFromBedFile(ploidyBedPath);
            }

            // load MAF
            this.MeanCoverage = CanvasIO.LoadVariantFrequencies(variantFrequencyFile, this.Segments);
            int medianVariantCoverage = AggregateVariantCoverage(ref this.Segments);


            // Create new models for different copy number states
            this.InitializePloidies();

            // Compute statistics on the copy number two regions
            float[] diploidCounts = AggregateCounts(ref this.Segments);
            DiploidCoverage         = CanvasCommon.Utilities.Mean(diploidCounts);
            CoverageWeightingFactor = CoverageWeighting / DiploidCoverage;


            // new coverage model
            this.Model            = new CoverageModel();
            Model.DiploidCoverage = DiploidCoverage;
            List <SegmentInfo> segments = new List <SegmentInfo>();

            foreach (CanvasSegment segment in this.Segments)
            {
                SegmentInfo info = new SegmentInfo();
                info.Segment = segment;
                List <double> MAF = new List <double>();
                foreach (float value in segment.VariantFrequencies)
                {
                    MAF.Add(value > 0.5 ? 1 - value : value);
                }

                if (MAF.Count > 0)
                {
                    info.MAF = CanvasCommon.Utilities.Median(MAF);
                }
                else
                {
                    info.MAF = -1;
                }

                info.Coverage = CanvasCommon.Utilities.Median(segment.Counts);

                if (this.Segments.Count > 100)
                {
                    info.Weight = segment.End - segment.Begin;
                }
                else
                {
                    info.Weight = segment.BinCount;
                }
                segments.Add(info);
            }

            // Assign copy number and major chromosome count for each segment
            bool useGaussianMixtureModel = false; // For now, this is set false, since we saw weird performance on chrY (CANV-115):

            if (useGaussianMixtureModel)
            {
                // optimize model covariance
                double likelihood = FitGaussians(Model, segments);
                AssignPloidyCallsGaussianMixture();
            }
            else
            {
                AssignPloidyCallsDistance(Model, segments, medianVariantCoverage);
            }

            // Merge neighboring segments that got the same copy number call.
            CanvasSegment.MergeSegments(ref this.Segments);
            CanvasSegment.AssignQualityScores(this.Segments, CanvasSegment.QScoreMethod.LogisticGermline);
            List <string> extraHeaders       = new List <string>();
            string        coverageOutputPath = CanvasCommon.Utilities.GetCoverageAndVariantFrequencyOutputPath(outFile);

            CanvasSegment.WriteCoveragePlotData(this.Segments, Model.DiploidCoverage, ploidy, coverageOutputPath, referenceFolder);

            if (this.CNOracle != null)
            {
                this.GenerateReportVersusKnownCN();
            }

            if (ploidy != null && !string.IsNullOrEmpty(ploidy.HeaderLine))
            {
                extraHeaders.Add(ploidy.HeaderLine);
            }
            CanvasSegment.WriteSegments(outFile, this.Segments, referenceFolder, sampleName, extraHeaders, ploidy);
            return(0);
        }
コード例 #19
0
        private void AssignPloidyCallsDistance(CoverageModel model, List <SegmentInfo> segments, int medianVariantCoverage)
        {
            List <ModelPoint> modelPoints = InitializeModelPoints(model);

            foreach (CanvasSegment segment in this.Segments)
            {
                // Compute (MAF, Coverage) for this segment:
                List <double> MAF = new List <double>();
                foreach (float VF in segment.VariantFrequencies)
                {
                    MAF.Add(VF > 0.5 ? 1 - VF : VF);
                }
                int expectedSnpDensityCutoff = (segment.End - segment.Begin) / MedianHetSnpsDistance / 2;


                List <Tuple <float, float> > weightedVariantFrequencies = new List <Tuple <float, float> >();
                double medianCoverage = CanvasCommon.Utilities.Median(segment.Counts);

                double medianMAF = -1;

                SegmentPloidy bestPloidy = null;

                if (MAF.Count >= Math.Max(10, expectedSnpDensityCutoff))
                {
                    medianMAF = Utilities.Median(MAF);
                }

                double bestDistance       = double.MaxValue;
                double secondBestDistance = double.MaxValue;

                foreach (SegmentPloidy ploidy in AllPloidies)
                {
                    double diff     = (ploidy.MixedCoverage - medianCoverage) * CoverageWeightingFactor;
                    double distance = diff * diff;
                    if (MAF.Count >= Math.Max(10, expectedSnpDensityCutoff))
                    {
                        diff      = ploidy.MixedMinorAlleleFrequency - medianMAF;
                        distance += diff * diff;
                    }
                    if (distance < bestDistance)
                    {
                        secondBestDistance = bestDistance;
                        bestDistance       = distance;
                        bestPloidy         = ploidy;
                    }
                    else if (distance < secondBestDistance)
                    {
                        secondBestDistance = distance;
                    }
                }
                segment.CopyNumber            = bestPloidy.CopyNumber;
                segment.ModelDistance         = bestDistance;
                segment.RunnerUpModelDistance = secondBestDistance;

                segment.MajorChromosomeCount = bestPloidy.MajorChromosomeCount;
                if (MAF.Count < 10)
                {
                    segment.MajorChromosomeCount = null;                 // Don't assign MCC if we don't have variant allele frequencies
                }
            }
        }
コード例 #20
0
        //Record Insurance
        public bool Record(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage)
        {
            InsuranceModel.InsuranceTypes type = insurance.InsuranceType;
            switch (type)
            {
            case InsuranceModel.InsuranceTypes.MOTOR_INSURANCE:
                return(RecordNewMotorInsurance(insurance, client, policyCoverage, document, coverage));

            case InsuranceModel.InsuranceTypes.LIFE_INSURANCE:
                return(RecordNewLifeInsurance(insurance, client, policyCoverage, document, coverage));

            default: return(false);
            }
            //_repository.Create(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage);
        }
コード例 #21
0
        public CoverageView(QWidget parent, String fileName) : base(parent)
        {
            SetRootIsDecorated(true);
            AddColumn("Classes");
            AddColumn("Lines Hit");
            AddColumn("Lines Missed");
            AddColumn("Coverage");

            sourceViews = new Hashtable();

            // TODO: Why the cast ?
            SetColumnAlignment(1, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment(2, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment(3, (int)Qt.AlignmentFlags.AlignCenter);

            QObject.Connect(this, SIGNAL("doubleClicked(QListViewItem)"),
                            this, SLOT("OnDoubleClick(QListViewItem)"));

            QObject.Connect(this,SIGNAL("expanded(QListViewItem)"),
                            this,SLOT("OnExpanded(QListViewItem)"));

            // TODO: This is not supported by current Qt#
            try {
                QObject.Connect(this,SIGNAL("contextMenuRequested(QListViewItem,QPoint,int)"),
                                this,SLOT("OnContextMenu(QListViewItem, QPoint, Int32)"));
            }
            catch (Exception) {
            }

            QPixmap namespaceOpenPixmap   = new QPixmap(namespace_open_xpm);
            QPixmap namespaceClosedPixmap = new QPixmap(namespace_closed_xpm);
            QPixmap classPixmap           = new QPixmap(class_xpm);

            model = new CoverageModel();
            foreach (string filter in DEFAULT_FILTERS)
            {
                model.AddFilter(filter);
            }
            model.ReadFromFile(fileName);

            QListViewItem rootItem = new TreeItem(this,"PROJECT",model);

            rootItem.SetOpen(true);

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable();

            foreach (string name in classes2.Keys)
            {
                ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

                if (klass.filtered)
                {
                    continue;
                }

                string        namespace2 = klass.name_space;
                NamespaceItem nsItem     = (NamespaceItem)namespaces [namespace2];
                if (nsItem == null)
                {
                    // Create namespaces
                    String        nsPrefix   = "";
                    QListViewItem parentItem = rootItem;
                    foreach (String nsPart in namespace2.Split('.'))
                    {
                        if (nsPrefix == "")
                        {
                            nsPrefix = nsPart;
                        }
                        else
                        {
                            nsPrefix = nsPrefix + "." + nsPart;
                        }

                        NamespaceCoverageItem nsModel = (NamespaceCoverageItem)model.Namespaces [nsPrefix];
                        if (nsModel.filtered)
                        {
                            break;
                        }

                        nsItem = (NamespaceItem)namespaces [nsPrefix];
                        if (nsItem == null)
                        {
                            nsItem = new NamespaceItem(parentItem,nsPrefix,
                                                       nsModel);
                            nsItem.SetOpen(true);
                            nsItem.SetPixmap(0,namespaceOpenPixmap);
                            namespaces [nsPrefix] = nsItem;
                        }
                        parentItem = nsItem;
                    }
                }

                if (nsItem != null)
                {
                    ClassItem classItem = new ClassItem(nsItem,klass.name,klass);
                    classItem.SetPixmap(0,classPixmap);
                    if (klass.ChildCount > 0)
                    {
                        classItem.SetExpandable(true);
                    }
                }
            }
        }
コード例 #22
0
ファイル: CoverageView.cs プロジェクト: alpinechough/monocov
        public CoverageView(string fileName, ProgressBar status)
        {
            store = new TreeStore (typeof(string), typeof(string), typeof(string), typeof(string), typeof(object));
            tree = new TreeView (store);

            CellRendererText renderer = new CellRendererText ();
            CellRendererText coverageRenderer = new CellRendererText ();
            // LAME: Why is this property a float instead of a double ?
            renderer.Xalign = 0.5f;

            tree.AppendColumn ("Classes", new CellRendererText (), "text", 0);
            tree.AppendColumn ("Lines Hit", renderer, "text", 1);
            tree.AppendColumn ("Lines Missed", renderer, "text", 2);
            tree.AppendColumn ("Coverage", coverageRenderer, "text", 3);

            tree.GetColumn (0).Resizable = true;
            tree.GetColumn (1).Alignment = 0.0f;
            tree.GetColumn (1).Resizable = true;
            tree.GetColumn (2).Alignment = 0.0f;
            tree.GetColumn (2).Resizable = true;
            tree.GetColumn (3).Alignment = 0.0f;
            tree.GetColumn (3).Resizable = true;
            tree.GetColumn (3).SetCellDataFunc (coverageRenderer, new TreeCellDataFunc (RenderCoverage));

            tree.HeadersVisible = true;

            model = new CoverageModel ();
            foreach (string filter in DEFAULT_FILTERS) {
                model.AddFilter (filter);
            }
            this.status = status;
            model.Progress += Progress;
            model.ReadFromFile (fileName);

            TreeItem root = new TreeItem (store, null, model, "PROJECT");

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable ();
            string[] sorted_names = new string[classes2.Count];
            classes2.Keys.CopyTo (sorted_names, 0);
            Array.Sort (sorted_names);
            Progress ("Building tree", 0.95);
            foreach (string name in sorted_names) {
                ClassCoverageItem klass = (ClassCoverageItem)classes2[name];

                if (klass.filtered)
                    continue;

                string namespace2 = klass.name_space;
                TreeItem nsItem = (TreeItem)namespaces[namespace2];
                if (nsItem == null) {
                    nsItem = new TreeItem (store, root, (CoverageItem)model.Namespaces[namespace2], namespace2);
                    //				nsItem.SetPixmap (0, namespaceOpenPixmap);
                    namespaces[namespace2] = nsItem;
                }

                if (nsItem.model.filtered)
                    continue;

                ClassItem classItem = new ClassItem (store, nsItem, klass, klass.name);

                if (klass.ChildCount != 0) {
                    TreeIter treeIter = store.AppendNode (classItem.iter);
                    store.SetValues (treeIter, "<loading>");
                }
            }

            tree.ExpandRow (store.GetPath (root.Iter), false);

            // it becomes very hard to navigate if everything is expanded
            //foreach (string ns in namespaces.Keys)
            //	tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false);

            tree.RowExpanded += new RowExpandedHandler (OnRowExpanded);
            tree.RowCollapsed += new RowCollapsedHandler (OnRowCollapsed);
            tree.ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress);
            tree.Selection.Mode = SelectionMode.Single;

            Progress ("Done", 1.0);
            // LAME: Why doesn't widgets visible by default ???
            tree.Show ();
        }
コード例 #23
0
 public virtual ResponseModel Send(CoverageModel coverageModel)
 {
     return(_coverageReceiver.Receive(coverageModel));
 }
コード例 #24
0
ファイル: MonoCov.cs プロジェクト: mono/monocov
        private static int handleExportXml(MonoCovOptions opts, string[] args)
        {
            if (args.Length == 0) {
            Console.WriteLine ("Error: Datafile name is required when using --export-xml");
            return 1;
            }

            if (!Directory.Exists (opts.exportXmlDir)) {
            try {
                Directory.CreateDirectory (opts.exportXmlDir);
            }
            catch (Exception ex) {
                Console.WriteLine ("Error: Destination directory '" + opts.exportXmlDir + "' does not exist and could not be created: " + ex);
                return 1;
            }
            }

            CoverageModel model = new CoverageModel ();
            model.ReadFromFile (args [0]);
            XmlExporter exporter = new XmlExporter ();
            exporter.DestinationDir = opts.exportXmlDir;
            exporter.StyleSheet = opts.styleSheet;
            if (!opts.quiet)
            exporter.Progress += new XmlExporter.ProgressEventHandler (progressListener);
            exporter.Export (model);
            if (!opts.quiet) {
            Console.WriteLine ();
            Console.WriteLine ("Done.");
            }
            return 0;
        }
コード例 #25
0
        public int CallVariants(string variantFrequencyFile, string inFile, string outFile, string ploidyVcfPath, string referenceFolder, string sampleName,
                                string truthDataPath)
        {
            if (!string.IsNullOrEmpty(truthDataPath))
            {
                _cnOracle = new CopyNumberOracle();
                _cnOracle.LoadKnownCN(truthDataPath);
            }

            _segments    = Segments.ReadSegments(_logger, new FileLocation(inFile));
            _allSegments = _segments.AllSegments.ToList();
            TempFolder   = Path.GetDirectoryName(inFile);
            if (_allSegments.Count == 0)
            {
                Console.WriteLine("CanvasDiploidCaller: No segments loaded; no CNV calls will be made.");
                CanvasSegmentWriter.WriteSegments(outFile, _allSegments, _model?.DiploidCoverage, referenceFolder,
                                                  sampleName, null, null, QualityFilterThreshold, false, null, null);
                return(0);
            }
            PloidyInfo ploidy = null;

            if (!string.IsNullOrEmpty(ploidyVcfPath))
            {
                ploidy = PloidyInfo.LoadPloidyFromVcfFileNoSampleId(ploidyVcfPath);
            }

            // load MAF
            var allelesByChromosome = CanvasIO.ReadFrequenciesWrapper(_logger, new FileLocation(variantFrequencyFile), _segments.IntervalsByChromosome);

            _segments.AddAlleles(allelesByChromosome);
            MeanCoverage = allelesByChromosome.SelectMany(x => x.Value).SelectMany(y => y.TotalCoverage).Average();
            AggregateVariantCoverage(ref _allSegments);

            // Create new models for different copy number states
            InitializePloidies();

            // Compute statistics on the copy number two regions
            float[] diploidCounts = AggregateCounts(ref _allSegments);
            _diploidCoverage         = Utilities.Mean(diploidCounts);
            _coverageWeightingFactor = CoverageWeighting / _diploidCoverage;
            // new coverage model
            _model = new CoverageModel {
                DiploidCoverage = _diploidCoverage
            };
            List <SegmentInfo> segments = new List <SegmentInfo>();

            foreach (CanvasSegment segment in _allSegments)
            {
                SegmentInfo info = new SegmentInfo {
                    Segment = segment
                };
                List <double> mafs = new List <double>();
                foreach (float value in segment.Balleles.Frequencies)
                {
                    mafs.Add(value > 0.5 ? 1 - value : value);
                }

                if (mafs.Count > 0)
                {
                    info.Maf = Utilities.Median(mafs);
                }
                else
                {
                    info.Maf = -1;
                }

                info.Coverage = Utilities.Median(segment.Counts);

                info.Weight = _allSegments.Count > 100 ? segment.Length : segment.BinCount;
                segments.Add(info);
            }

            AssignPloidyCallsDistance(_model);

            CanvasSegment.AssignQualityScores(_allSegments, CanvasSegment.QScoreMethod.LogisticGermline, _germlineScoreParameters);

            // Merge neighboring segments that got the same copy number call.
            // merging segments requires quality scores so we do it after quality scores have been assigned
            var mergedSegments = CanvasSegment.MergeSegments(_allSegments);

            // recalculating qscores after merging segments improves performance!

            CanvasSegment.AssignQualityScores(mergedSegments, CanvasSegment.QScoreMethod.LogisticGermline, _germlineScoreParameters);
            CanvasSegment.SetFilterForSegments(QualityFilterThreshold, mergedSegments, CanvasFilter.SegmentSizeCutoff);

            List <string> extraHeaders       = new List <string>();
            var           coverageOutputPath = SingleSampleCallset.GetCoverageAndVariantFrequencyOutputPath(outFile);

            CanvasSegment.WriteCoveragePlotData(mergedSegments, _model.DiploidCoverage, ploidy, coverageOutputPath, referenceFolder);

            if (_cnOracle != null)
            {
                GenerateReportVersusKnownCopyNumber();
            }

            if (!string.IsNullOrEmpty(ploidy?.HeaderLine))
            {
                extraHeaders.Add(ploidy.HeaderLine);
            }

            CanvasSegmentWriter.WriteSegments(outFile, mergedSegments, _model.DiploidCoverage, referenceFolder, sampleName,
                                              extraHeaders, ploidy, QualityFilterThreshold, false, null, null);
            return(0);
        }
コード例 #26
0
        private void AssignPloidyCallsDistance(CoverageModel model)
        {
            InitializeModelPoints(model);
            foreach (CanvasSegment segment in _allSegments)
            {
                // Compute (MAF, Coverage) for this segment:
                List <double> mafs = new List <double>();
                foreach (float variantFrequency in segment.Balleles.Frequencies)
                {
                    mafs.Add(variantFrequency > 0.5 ? 1 - variantFrequency : variantFrequency);
                }
                int expectedSnpDensityCutoff = (segment.Length) / MedianHetSnpsDistance / 2;

                double medianCoverage = Utilities.Median(segment.Counts);

                double medianMaf = -1;

                SegmentPloidy bestPloidy = null;

                if (mafs.Count >= Math.Max(10, expectedSnpDensityCutoff))
                {
                    medianMaf = Utilities.Median(mafs);
                }

                double bestDistance       = double.MaxValue;
                double secondBestDistance = double.MaxValue;

                foreach (SegmentPloidy ploidy in _allPloidies)
                {
                    double diff     = (ploidy.MixedCoverage - medianCoverage) * _coverageWeightingFactor;
                    double distance = diff * diff;
                    if (mafs.Count >= Math.Max(10, expectedSnpDensityCutoff))
                    {
                        diff      = ploidy.MixedMinorAlleleFrequency - medianMaf;
                        distance += diff * diff;
                    }
                    if (distance < bestDistance)
                    {
                        secondBestDistance = bestDistance;
                        bestDistance       = distance;
                        bestPloidy         = ploidy;
                    }
                    else if (distance < secondBestDistance)
                    {
                        secondBestDistance = distance;
                    }
                }
                if (bestPloidy != null)
                {
                    segment.CopyNumber           = bestPloidy.CopyNumber;
                    segment.MajorChromosomeCount = bestPloidy.MajorChromosomeCount;
                }
                segment.ModelDistance         = bestDistance;
                segment.RunnerUpModelDistance = secondBestDistance;

                if (mafs.Count < 10)
                {
                    segment.MajorChromosomeCount = null;                  // Don't assign MCC if we don't have variant allele frequencies
                }
            }
        }
コード例 #27
0
        //Business Logics for Motor Insurance
        private bool RecordNewMotorInsurance(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage)
        {
            ValidateAddInsurance validation = new ValidateAddInsurance();
            bool isCorrectAge = validation.ValidateForAge(client.Age);

            //_repository.Create(InsuranceModel insurance, ClientModel client, PolicyCoverageDetailModel policyCoverage, DocumentModel document, CoverageModel coverage);
            throw new NotImplementedException();
        }
コード例 #28
0
	public CoverageView (string fileName, ProgressBar status)
	{
		TreeStore store = new TreeStore (typeof (string), typeof (string), typeof (string), typeof (string), typeof (object));
		tree = new TreeView (store);

		CellRendererText renderer = new CellRendererText ();
		// LAME: Why is this property a float instead of a double ?
		renderer.Xalign = 0.5f;

		tree.AppendColumn ("Classes", new CellRendererText (), "text", 0);
		tree.AppendColumn ("Lines Hit", renderer, "text", 1);
		tree.AppendColumn ("Lines Missed", renderer, "text", 2);
		tree.AppendColumn ("Coverage", renderer, "text", 3);

		tree.GetColumn (0).Resizable = true;
		tree.GetColumn (1).Alignment = 0.0f;
		tree.GetColumn (1).Resizable = true;
		tree.GetColumn (2).Alignment = 0.0f;
		tree.GetColumn (2).Resizable = true;
		tree.GetColumn (3).Alignment = 0.0f;
		tree.GetColumn (3).Resizable = true;

		tree.HeadersVisible = true;

		model = new CoverageModel ();
		foreach (string filter in DEFAULT_FILTERS) {
			model.AddFilter (filter);
		}
		this.status = status;
		model.Progress += Progress;
		model.ReadFromFile (fileName);

		TreeItem root = new TreeItem (store, null, model, "PROJECT");

		Hashtable classes2 = model.Classes;

		namespaces = new Hashtable ();
		string[] sorted_names = new string [classes2.Count];
		classes2.Keys.CopyTo (sorted_names, 0);
		Array.Sort (sorted_names);
		Progress ("Building tree", 0.95);
		foreach (string name in sorted_names) {
			ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

			if (klass.filtered)
				continue;

			string namespace2 = klass.name_space;
			TreeItem nsItem = (TreeItem)namespaces [namespace2];
			if (nsItem == null) {
				nsItem = new TreeItem (store, root, (CoverageItem)model.Namespaces [namespace2], namespace2);
				//				nsItem.SetPixmap (0, namespaceOpenPixmap);
				namespaces [namespace2] = nsItem;
			}

			if (nsItem.model.filtered)
				continue;

			ClassItem classItem = new ClassItem (store, nsItem, klass, klass.name);

			// We should create the method nodes only when the class item
			// is opened
			
			foreach (MethodCoverageItem method in klass.Methods) {
				if (method.filtered)
					continue;

				string title = method.Name;
				if (title.Length > 64)
					title = title.Substring (0, 63) + "...)";

				new MethodItem (store, classItem, classItem, method, title);
			}
		}

		tree.ExpandRow (store.GetPath (root.Iter), false);

		// it becomes very hard to navigate if everything is expanded
		//foreach (string ns in namespaces.Keys)
		//	tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false);

		tree.ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress);
		tree.Selection.Mode = SelectionMode.Single;

		source_views = new Hashtable ();
		window_maps = new Hashtable ();
		Progress ("Done", 1.0);
		// LAME: Why doesn't widgets visible by default ???
		tree.Show ();
	}
コード例 #29
0
ファイル: CoverageView.cs プロジェクト: bennidhamma/monocov
        public CoverageView(QWidget parent, String fileName)
            : base(parent)
        {
            SetRootIsDecorated (true);
            AddColumn ("Classes");
            AddColumn ("Lines Hit");
            AddColumn ("Lines Missed");
            AddColumn ("Coverage");

            sourceViews = new Hashtable ();

            // TODO: Why the cast ?
            SetColumnAlignment (1, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment (2, (int)Qt.AlignmentFlags.AlignCenter);
            SetColumnAlignment (3, (int)Qt.AlignmentFlags.AlignCenter);

            QObject.Connect (this, SIGNAL ("doubleClicked(QListViewItem)"),
                         this, SLOT ("OnDoubleClick(QListViewItem)"));

            QObject.Connect (this, SIGNAL ("expanded(QListViewItem)"),
                         this, SLOT ("OnExpanded(QListViewItem)"));

            // TODO: This is not supported by current Qt#
            try {
            QObject.Connect (this, SIGNAL ("contextMenuRequested(QListViewItem,QPoint,int)"),
                             this, SLOT ("OnContextMenu(QListViewItem, QPoint, Int32)"));
            }
            catch (Exception) {
            }

            QPixmap namespaceOpenPixmap = new QPixmap (namespace_open_xpm);
            QPixmap namespaceClosedPixmap = new QPixmap (namespace_closed_xpm);
            QPixmap classPixmap = new QPixmap (class_xpm);

            model = new CoverageModel ();
            foreach (string filter in DEFAULT_FILTERS) {
            model.AddFilter (filter);
            }
            model.ReadFromFile (fileName);

            QListViewItem rootItem = new TreeItem (this, "PROJECT", model);
            rootItem.SetOpen (true);

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable ();

            foreach (string name in classes2.Keys) {
            ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

            if (klass.filtered)
                continue;

            string namespace2 = klass.name_space;
            NamespaceItem nsItem = (NamespaceItem)namespaces [namespace2];
            if (nsItem == null) {
                // Create namespaces
                String nsPrefix = "";
                QListViewItem parentItem = rootItem;
                foreach (String nsPart in namespace2.Split ('.')) {
                    if (nsPrefix == "")
                        nsPrefix = nsPart;
                    else
                        nsPrefix = nsPrefix + "." + nsPart;

                    NamespaceCoverageItem nsModel = (NamespaceCoverageItem)model.Namespaces [nsPrefix];
                    if (nsModel.filtered)
                        break;

                    nsItem = (NamespaceItem)namespaces [nsPrefix];
                    if (nsItem == null) {
                        nsItem = new NamespaceItem (parentItem, nsPrefix,
                                                    nsModel);
                        nsItem.SetOpen (true);
                        nsItem.SetPixmap (0, namespaceOpenPixmap);
                        namespaces [nsPrefix] = nsItem;
                    }
                    parentItem = nsItem;
                }
            }

            if (nsItem != null) {
                ClassItem classItem = new ClassItem (nsItem, klass.name, klass);
                classItem.SetPixmap (0, classPixmap);
                if (klass.ChildCount > 0)
                    classItem.SetExpandable (true);
            }
            }
        }