Example #1
0
 internal StatementBinding(
     BoundStatement boundStatement,
     ImmutableMap<SyntaxNode, BlockBaseBinderContext> blockMap,
     IList<LocalSymbol> locals,
     Dictionary<SyntaxNode, BoundNode> nodeMap,
     DiagnosticBag diagnostics)
 {
     this.boundStatement = boundStatement;
     this.blockMap = blockMap;
     this.locals = locals;
     this.nodeMap = nodeMap;
     this.diagnostics = diagnostics;
 }
 internal FakeMemberSemanticModel(Compilation compilation, SyntaxNode root, SourceMethodSymbol method, Binder rootBinder, ImmutableMap<SyntaxNode, Binder> map)
     : base(compilation, root, method)
 {
     this.rootBinder = rootBinder;
     this.map = map;
 }
 internal ExternalEnumNames(ExtendedEnum <T> extendedEnum, string group, ImmutableMap <string, string> externalNames)
 {
     this.extendedEnum          = extendedEnum;
     this.group                 = group;
     this.externalNames_Renamed = externalNames;
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="type">  the enum type </param>
 /// <param name="lookups">  the lookup functions to find instances </param>
 /// <param name="alternateNames">  the map of alternate name to standard name </param>
 /// <param name="externalNames">  the map of external name groups </param>
 private ExtendedEnum(Type <T> type, ImmutableList <NamedLookup <T> > lookups, ImmutableMap <string, string> alternateNames, ImmutableMap <string, ImmutableMap <string, string> > externalNames, ImmutableList <Pair <Pattern, string> > lenientRegex)
 {
     this.type    = ArgChecker.notNull(type, "type");
     this.lookups = ArgChecker.notNull(lookups, "lookups");
     this.alternateNames_Renamed = ArgChecker.notNull(alternateNames, "alternateNames");
     this.externalNames_Renamed  = ArgChecker.notNull(externalNames, "externalNames");
     this.lenientRegex           = ArgChecker.notNull(lenientRegex, "lenientRegex");
 }
 public NamedLookupAnonymousInnerClass(ImmutableMap <string, R> constants)
 {
     this.constants = constants;
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an extended enum instance.
 /// <para>
 /// Calling this method loads configuration files to determine the extended enum values.
 /// The configuration file has the same simple name as the specified type and is a
 /// <seealso cref="IniFile INI file"/> with the suffix '.ini'.
 /// See class-level documentation for more information.
 ///
 /// </para>
 /// </summary>
 /// @param <R>  the type of the enum </param>
 /// <param name="type">  the type to load </param>
 /// <returns> the extended enum </returns>
 public static ExtendedEnum <R> of <R>(Type <R> type) where R : Named
 {
     try
     {
         // load all matching files
         string  name   = type.Name + ".ini";
         IniFile config = ResourceConfig.combinedIniFile(name);
         // parse files
         ImmutableList <NamedLookup <R> > lookups        = parseProviders(config, type);
         ImmutableMap <string, string>    alternateNames = parseAlternates(config);
         ImmutableMap <string, ImmutableMap <string, string> > externalNames = parseExternals(config);
         ImmutableList <Pair <Pattern, string> > lenientRegex = parseLenientPatterns(config);
         log.fine(() => "Loaded extended enum: " + name + ", providers: " + lookups);
         return(new ExtendedEnum <R>(type, lookups, alternateNames, externalNames, lenientRegex));
     }
     catch (Exception ex)
     {
         // logging used because this is loaded in a static variable
         log.severe("Failed to load ExtendedEnum for " + type + ": " + Throwables.getStackTraceAsString(ex));
         // return an empty instance to avoid ExceptionInInitializerError
         return(new ExtendedEnum <R>(type, ImmutableList.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of()));
     }
 }
Example #7
0
        //-------------------------------------------------------------------------
        private ScenarioMarketData marketData()
        {
            TestMarketDataMap md = new TestMarketDataMap(VAL_DATE, ImmutableMap.of(QuoteId.of(SEC_ID.StandardId), MARKET_PRICE), ImmutableMap.of());

            return(md);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            LegalEntityCurveGroup test1 = LegalEntityCurveGroup.of(NAME1, REPO_CURVES, ISSUER_CURVES);

            coverImmutableBean(test1);
            LegalEntityCurveGroup test2 = LegalEntityCurveGroup.of(NAME1, ImmutableMap.of(), ImmutableMap.of());

            coverBeanEquals(test1, test2);
        }
Example #9
0
        //-------------------------------------------------------------------------
        internal static ScenarioMarketData marketData()
        {
            CurveParameterSize        issuerSize   = CurveParameterSize.of(ISSUER_CURVE_ID.CurveName, 3);
            CurveParameterSize        repoSize     = CurveParameterSize.of(REPO_CURVE_ID.CurveName, 2);
            JacobianCalibrationMatrix issuerMatrix = JacobianCalibrationMatrix.of(ImmutableList.of(issuerSize, repoSize), DoubleMatrix.copyOf(new double[][]
            {
                new double[] { 0.95, 0.03, 0.01, 0.006, 0.004 },
                new double[] { 0.03, 0.95, 0.01, 0.005, 0.005 },
                new double[] { 0.03, 0.01, 0.95, 0.002, 0.008 }
            }));
            JacobianCalibrationMatrix repoMatrix = JacobianCalibrationMatrix.of(ImmutableList.of(issuerSize, repoSize), DoubleMatrix.copyOf(new double[][]
            {
                new double[] { 0.003, 0.003, 0.004, 0.97, 0.02 },
                new double[] { 0.003, 0.006, 0.001, 0.05, 0.94 }
            }));
            CurveMetadata issuerMetadata = Curves.zeroRates(ISSUER_CURVE_ID.CurveName, ACT_360).withInfo(CurveInfoType.JACOBIAN, issuerMatrix);
            CurveMetadata repoMetadata   = Curves.zeroRates(REPO_CURVE_ID.CurveName, ACT_360).withInfo(CurveInfoType.JACOBIAN, repoMatrix);
            Curve         issuerCurve    = InterpolatedNodalCurve.of(issuerMetadata, DoubleArray.of(1.0, 5.0, 10.0), DoubleArray.of(0.02, 0.04, 0.01), CurveInterpolators.LINEAR);
            Curve         repoCurve      = InterpolatedNodalCurve.of(repoMetadata, DoubleArray.of(0.5, 3.0), DoubleArray.of(0.005, 0.008), CurveInterpolators.LINEAR);

            return(new TestMarketDataMap(VAL_DATE, ImmutableMap.of(REPO_CURVE_ID, repoCurve, ISSUER_CURVE_ID, issuerCurve, QUOTE_ID, SETTLE_PRICE * 100), ImmutableMap.of()));
        }
        public virtual void TestSerilizationAfterRecovery()
        {
            //(timeout = 10000)
            mgr.AddToCluserNodeLabels(ToSet("p1", "p2", "p3"));
            mgr.AddToCluserNodeLabels(ToSet("p4"));
            mgr.AddToCluserNodeLabels(ToSet("p5", "p6"));
            mgr.ReplaceLabelsOnNode(ImmutableMap.Of(ToNodeId("n1"), ToSet("p1"), ToNodeId("n2"
                                                                                          ), ToSet("p2")));
            mgr.ReplaceLabelsOnNode((IDictionary)ImmutableMap.Of(ToNodeId("n3"), ToSet("p3"),
                                                                 ToNodeId("n4"), ToSet("p4"), ToNodeId("n5"), ToSet("p5"), ToNodeId("n6"), ToSet(
                                                                     "p6"), ToNodeId("n7"), ToSet("p6")));

            /*
             * node -> labels
             * p1: n1
             * p2: n2
             * p3: n3
             * p4: n4
             * p5: n5
             * p6: n6, n7
             */
            mgr.RemoveFromClusterNodeLabels(ToSet("p1"));
            mgr.RemoveFromClusterNodeLabels(Arrays.AsList("p3", "p5"));

            /*
             * After removed
             * p2: n2
             * p4: n4
             * p6: n6, n7
             */
            // shutdown mgr and start a new mgr
            mgr.Stop();
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            // check variables
            NUnit.Framework.Assert.AreEqual(3, mgr.GetClusterNodeLabels().Count);
            NUnit.Framework.Assert.IsTrue(mgr.GetClusterNodeLabels().ContainsAll(Arrays.AsList
                                                                                     ("p2", "p4", "p6")));
            AssertMapContains(mgr.GetNodeLabels(), ImmutableMap.Of(ToNodeId("n2"), ToSet("p2"
                                                                                         ), ToNodeId("n4"), ToSet("p4"), ToNodeId("n6"), ToSet("p6"), ToNodeId("n7"), ToSet
                                                                       ("p6")));
            AssertLabelsToNodesEquals(mgr.GetLabelsToNodes(), ImmutableMap.Of("p6", ToSet(ToNodeId
                                                                                              ("n6"), ToNodeId("n7")), "p4", ToSet(ToNodeId("n4")), "p2", ToSet(ToNodeId("n2")
                                                                                                                                                                )));

            /*
             * Add label p7,p8 then shutdown
             */
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            mgr.AddToCluserNodeLabels(ToSet("p7", "p8"));
            mgr.Stop();

            /*
             * Restart, add label p9 and shutdown
             */
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            mgr.AddToCluserNodeLabels(ToSet("p9"));
            mgr.Stop();

            /*
             * Recovery, and see if p9 added
             */
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            // check variables
            NUnit.Framework.Assert.AreEqual(6, mgr.GetClusterNodeLabels().Count);
            NUnit.Framework.Assert.IsTrue(mgr.GetClusterNodeLabels().ContainsAll(Arrays.AsList
                                                                                     ("p2", "p4", "p6", "p7", "p8", "p9")));
            mgr.Stop();
        }
 private double[] getStandardQuoteForm(ResolvedCdsTrade calibrationCds, CdsQuote marketQuote, LocalDate valuationDate, CreditDiscountFactors discountFactors, RecoveryRates recoveryRates, bool computeJacobian, ReferenceData refData)
 {
     double[] res = new double[3];
     res[2] = 1d;
     if (marketQuote.QuoteConvention.Equals(CdsQuoteConvention.PAR_SPREAD))
     {
         res[0] = marketQuote.QuotedValue;
     }
     else if (marketQuote.QuoteConvention.Equals(CdsQuoteConvention.QUOTED_SPREAD))
     {
         double     qSpread                 = marketQuote.QuotedValue;
         CurveName  curveName               = CurveName.of("quoteConvertCurve");
         NodalCurve tempCreditCurve         = calibrate(ImmutableList.of(calibrationCds), DoubleArray.of(qSpread), DoubleArray.of(0d), curveName, valuationDate, discountFactors, recoveryRates, refData);
         Currency   currency                = calibrationCds.Product.Currency;
         StandardId legalEntityId           = calibrationCds.Product.LegalEntityId;
         ImmutableCreditRatesProvider rates = ImmutableCreditRatesProvider.builder().valuationDate(valuationDate).discountCurves(ImmutableMap.of(currency, discountFactors)).recoveryRateCurves(ImmutableMap.of(legalEntityId, recoveryRates)).creditCurves(ImmutableMap.of(Pair.of(legalEntityId, currency), LegalEntitySurvivalProbabilities.of(legalEntityId, IsdaCreditDiscountFactors.of(currency, valuationDate, tempCreditCurve)))).build();
         res[0] = calibrationCds.Product.FixedRate;
         res[1] = tradePricer.price(calibrationCds, rates, PriceType.CLEAN, refData);
         if (computeJacobian)
         {
             CurrencyParameterSensitivities pufSensi = rates.parameterSensitivity(tradePricer.priceSensitivity(calibrationCds, rates, refData));
             CurrencyParameterSensitivities spSensi  = rates.parameterSensitivity(tradePricer.parSpreadSensitivity(calibrationCds, rates, refData));
             res[2] = spSensi.getSensitivity(curveName, currency).Sensitivity.get(0) / pufSensi.getSensitivity(curveName, currency).Sensitivity.get(0);
         }
     }
     else if (marketQuote.QuoteConvention.Equals(CdsQuoteConvention.POINTS_UPFRONT))
     {
         res[0] = calibrationCds.Product.FixedRate;
         res[1] = marketQuote.QuotedValue;
     }
     else
     {
         throw new System.ArgumentException("Unknown CDSQuoteConvention type " + marketQuote.GetType());
     }
     return(res);
 }
        internal virtual LegalEntitySurvivalProbabilities calibrate(IList <CdsIsdaCreditCurveNode> curveNodes, CurveName name, MarketData marketData, ImmutableCreditRatesProvider ratesProvider, DayCount definitionDayCount, Currency definitionCurrency, bool computeJacobian, bool storeTrade, ReferenceData refData)
        {
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IEnumerator <StandardId> legalEntities = curveNodes.Select(CdsIsdaCreditCurveNode::getLegalEntityId).collect(Collectors.toSet()).GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            StandardId legalEntityId = legalEntities.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            ArgChecker.isFalse(legalEntities.hasNext(), "legal entity must be common to curve nodes");
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IEnumerator <Currency> currencies = curveNodes.Select(n => n.Template.Convention.Currency).collect(Collectors.toSet()).GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Currency currency = currencies.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            ArgChecker.isFalse(currencies.hasNext(), "currency must be common to curve nodes");
            ArgChecker.isTrue(definitionCurrency.Equals(currency), "curve definition currency must be the same as the currency of CDS");
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            IEnumerator <CdsQuoteConvention> quoteConventions = curveNodes.Select(n => n.QuoteConvention).collect(Collectors.toSet()).GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            CdsQuoteConvention quoteConvention = quoteConventions.next();

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            ArgChecker.isFalse(quoteConventions.hasNext(), "quote convention must be common to curve nodes");
            LocalDate valuationDate = marketData.ValuationDate;

            ArgChecker.isTrue(valuationDate.Equals(marketData.ValuationDate), "ratesProvider and marketDate must be based on the same valuation date");
            CreditDiscountFactors discountFactors = ratesProvider.discountFactors(currency);

            ArgChecker.isTrue(definitionDayCount.Equals(discountFactors.DayCount), "credit curve and discount curve must be based on the same day count convention");
            RecoveryRates recoveryRates = ratesProvider.recoveryRates(legalEntityId);

            int nNodes = curveNodes.Count;

            double[] coupons = new double[nNodes];
            double[] pufs    = new double[nNodes];
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: double[][] diag = new double[nNodes][nNodes];
            double[][] diag = RectangularArrays.ReturnRectangularDoubleArray(nNodes, nNodes);
            ImmutableList.Builder <ResolvedCdsTrade> tradesBuilder = ImmutableList.builder();
            for (int i = 0; i < nNodes; i++)
            {
                CdsCalibrationTrade tradeCalibration = curveNodes[i].trade(1d, marketData, refData);
                ResolvedCdsTrade    trade            = tradeCalibration.UnderlyingTrade.resolve(refData);
                tradesBuilder.add(trade);
                double[] temp = getStandardQuoteForm(trade, tradeCalibration.Quote, valuationDate, discountFactors, recoveryRates, computeJacobian, refData);
                coupons[i] = temp[0];
                pufs[i]    = temp[1];
                diag[i][i] = temp[2];
            }
            ImmutableList <ResolvedCdsTrade> trades = tradesBuilder.build();
            NodalCurve nodalCurve = calibrate(trades, DoubleArray.ofUnsafe(coupons), DoubleArray.ofUnsafe(pufs), name, valuationDate, discountFactors, recoveryRates, refData);

            if (computeJacobian)
            {
                LegalEntitySurvivalProbabilities            creditCurve      = LegalEntitySurvivalProbabilities.of(legalEntityId, IsdaCreditDiscountFactors.of(currency, valuationDate, nodalCurve));
                ImmutableCreditRatesProvider                ratesProviderNew = ratesProvider.toBuilder().creditCurves(ImmutableMap.of(Pair.of(legalEntityId, currency), creditCurve)).build();
                System.Func <ResolvedCdsTrade, DoubleArray> sensiFunc        = quoteConvention.Equals(CdsQuoteConvention.PAR_SPREAD) ? getParSpreadSensitivityFunction(ratesProviderNew, name, currency, refData) : getPointsUpfrontSensitivityFunction(ratesProviderNew, name, currency, refData);
                DoubleMatrix sensi = DoubleMatrix.ofArrayObjects(nNodes, nNodes, i => sensiFunc(trades.get(i)));
                sensi = (DoubleMatrix)MATRIX_ALGEBRA.multiply(DoubleMatrix.ofUnsafe(diag), sensi);
                JacobianCalibrationMatrix jacobian = JacobianCalibrationMatrix.of(ImmutableList.of(CurveParameterSize.of(name, nNodes)), MATRIX_ALGEBRA.getInverse(sensi));
                nodalCurve = nodalCurve.withMetadata(nodalCurve.Metadata.withInfo(CurveInfoType.JACOBIAN, jacobian));
            }

            ImmutableList <ParameterMetadata> parameterMetadata;

            if (storeTrade)
            {
                parameterMetadata = IntStream.range(0, nNodes).mapToObj(n => ResolvedTradeParameterMetadata.of(trades.get(n), curveNodes[n].Label)).collect(Guavate.toImmutableList());
            }
            else
            {
                parameterMetadata = IntStream.range(0, nNodes).mapToObj(n => curveNodes[n].metadata(trades.get(n).Product.ProtectionEndDate)).collect(Guavate.toImmutableList());
            }
            nodalCurve = nodalCurve.withMetadata(nodalCurve.Metadata.withParameterMetadata(parameterMetadata));

            return(LegalEntitySurvivalProbabilities.of(legalEntityId, IsdaCreditDiscountFactors.of(currency, valuationDate, nodalCurve)));
        }
Example #13
0
        //-------------------------------------------------------------------------
        internal static ScenarioMarketData marketData()
        {
            Curve             curve1 = ConstantCurve.of(Curves.discountFactors("Test", ACT_360), 0.992);
            Curve             curve2 = ConstantCurve.of(Curves.discountFactors("Test", ACT_360), 0.991);
            TestMarketDataMap md     = new TestMarketDataMap(VAL_DATE, ImmutableMap.of(DISCOUNT_CURVE_GBP_ID, curve1, DISCOUNT_CURVE_USD_ID, curve2, FxRateId.of(GBP, USD), FxRate.of(GBP, USD, 1.62)), ImmutableMap.of());

            return(md);
        }
Example #14
0
        static BondFuturesJpyEnd2EndTest()
        {
            for (int i = 0; i < NB_UND_BONDS; ++i)
            {
                PeriodicSchedule periodSchedule = PeriodicSchedule.of(START_DATE[i], MATURITY_DATE[i], Frequency.P6M, BUSINESS_ADJUST, StubConvention.SHORT_INITIAL, false);
                FixedCouponBond  product        = FixedCouponBond.builder().securityId(SecurityId.of(BOND_SECURITY_ID[i])).dayCount(DAY_COUNT).fixedRate(UND_RATES[i] * ONE_PERCENT).legalEntityId(ISSUER_ID).currency(JPY).notional(NOTIONAL).accrualSchedule(periodSchedule).settlementDateOffset(SETTLEMENT_DAYS).yieldConvention(YIELD_CONVENTION).build();
                UND_BOND[i] = product;
            }
            UND_BOND_SEP = new FixedCouponBond[NB_UND_BONDS - 2];
            Array.Copy(UND_BOND, 2, UND_BOND_SEP, 0, NB_UND_BONDS - 2);
            UND_BOND_JUN = new FixedCouponBond[NB_UND_BONDS - 1];
            Array.Copy(UND_BOND, 1, UND_BOND_JUN, 0, NB_UND_BONDS - 1);
            double[]               timeIssuer  = new double[] { 0.25136612021857924, 0.4972677595628415, 1.0139980537465378, 2.013998053746538, 2.857833670184894, 3.857833670184894, 4.860655737704918, 5.857833670184894, 7.104409012650647, 7.857833670184894, 8.857923497267759, 9.863313122239688, 14.857833670184894, 19.857833670184895, 29.857833670184895, 39.11262819073284 };
            double[]               rateIssuer  = new double[] { -0.0013117084834668065, -0.0010851901424876163, -0.0020906775838723216, -0.0022137102045172784, -0.0022695678374162888, -0.0023424568490920798, -0.0021603059162879916, -0.0021667343131861225, -0.0018285921969274823, -0.001355094018965514, -6.763044056712535E-4, 1.9555294306801752E-4, 0.003944125562941363, 0.008054233458390252, 0.012276105941434846, 0.013537766297065804 };
            double[]               timeRepo    = new double[] { 0.00273224043715847, 0.01912568306010929, 0.040983606557377046, 0.05737704918032787, 0.07923497267759563, 0.2459016393442623, 0.4972677595628415, 1.0002994236095515 };
            double[]               rateRepo    = new double[] { 2.599662058772748E-4, -8.403529976927196E-4, -0.0010105103936934236, -0.0011506617573950931, -0.0012708071334455143, -0.00146106683851595, -0.0014710815100096722, -0.001481096281798276 };
            CurveMetadata          metaIssuer  = Curves.zeroRates(ISSUER_CURVE_NAME, ACT_ACT_ISDA);
            InterpolatedNodalCurve curveIssuer = InterpolatedNodalCurve.of(metaIssuer, DoubleArray.copyOf(timeIssuer), DoubleArray.copyOf(rateIssuer), INTERPOLATOR);
            DiscountFactors        dscIssuer   = ZeroRateDiscountFactors.of(JPY, VALUATION, curveIssuer);
            CurveMetadata          metaRepo    = Curves.zeroRates(REPO_CURVE_NAME, ACT_ACT_ISDA);
            InterpolatedNodalCurve curve       = InterpolatedNodalCurve.of(metaRepo, DoubleArray.copyOf(timeRepo), DoubleArray.copyOf(rateRepo), INTERPOLATOR);
            DiscountFactors        dscRepo     = ZeroRateDiscountFactors.of(JPY, VALUATION, curve);

            LED_PROVIDER = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, JPY), dscIssuer)).issuerCurveGroups(ImmutableMap.of(ISSUER_ID, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO, JPY), dscRepo)).repoCurveGroups(ImmutableMap.of(ISSUER_ID, GROUP_REPO)).build();
        }
Example #15
0
        public virtual void test_of_repeated()
        {
            ScenarioMarketData test = ScenarioMarketData.of(1, MarketData.of(VAL_DATE, ImmutableMap.of(ID1, VAL1)));

            assertThat(test.ValuationDate).isEqualTo(MarketDataBox.ofSingleValue(VAL_DATE));
            assertThat(test.getValue(ID1)).isEqualTo(MarketDataBox.ofSingleValue(VAL1));
        }
        void setData(object sender, DoWorkEventArgs e)
        {
            Protein protein = e.Argument as Protein;

            if (viewFilter.HasSpectrumFilter || viewFilter.HasModificationFilter || !viewFilter.Analysis.IsNullOrEmpty())
            {
                viewFilter = new DataFilter(viewFilter);
                lock (session)
                    this.viewFilter.Peptide = session.CreateQuery("SELECT psm.Peptide " +
                                                                  viewFilter.GetFilteredQueryString(DataFilter.FromPeptideSpectrumMatch,
                                                                                                    DataFilter.PeptideSpectrumMatchToSpectrumSourceGroupLink))
                                                     .List<Peptide>();
            }

            if (protein == Protein)
                return;

            var query = session.CreateQuery("SELECT pi.Offset+pm.Offset, pm " +
                                            "FROM PeptideInstance pi " +
                                            "JOIN pi.Peptide pep " +
                                            "JOIN pep.Matches psm " +
                                            "JOIN psm.Modifications pm " +
                                            "JOIN FETCH pm.Modification mod " +
                                            "WHERE pi.Protein=" + protein.Id.ToString());

            IList<object[]> queryRows;
            lock (session) queryRows = query.List<object[]>();

            var modifications = new Map<int, PeptideModification>();
            foreach (var queryRow in queryRows)
                modifications[Convert.ToInt32(queryRow[0])] = queryRow[1] as PeptideModification;

            Protein = protein;
            Modifications = new ImmutableMap<int, PeptideModification>(modifications);
        }
Example #17
0
 internal FxMatrixBuilder(ImmutableMap <Currency, int> currencies, double[][] rates)
 {
     this.currencies = new LinkedHashMap <Currency, int>(currencies);
     // Ensure there is space to add at least one new currency
     this.rates = copyArray(rates, size(currencies.size() + 1));
 }