Example #1
0
        /// <summary>
        /// Generate a profileAlignment from one single sequence
        /// The set of sequence items of the seq should be the same as
        /// 'static ItemSet' of the IProfiles.
        /// </summary>
        /// <param name="seq">an input sequence</param>
        /// <param name="weight">sequence weight</param>
        public static IProfileAlignment GenerateProfileAlignment(ISequence seq, float weight)
        {
            IProfiles         profileMatrix    = Profiles.GenerateProfiles(seq, weight);
            IProfileAlignment profileAlignment = new ProfileAlignment();

            profileAlignment.NumberOfSequences = 1;
            profileAlignment.ProfilesMatrix    = profileMatrix;
            return(profileAlignment);
        }
Example #2
0
        /// <summary>
        /// Generate IProfileAlignment from a set of aligned sequences
        /// </summary>
        /// <param name="sequences">aligned sequences</param>
        public static IProfileAlignment GenerateProfileAlignment(ICollection <ISequence> sequences)
        {
            IProfiles         profileMatrix    = Profiles.GenerateProfiles(sequences);
            IProfileAlignment profileAlignment = new ProfileAlignment();

            profileAlignment.NumberOfSequences = sequences.Count;
            profileAlignment.ProfilesMatrix    = profileMatrix;
            return(profileAlignment);
        }
Example #3
0
        /// <summary>
        /// Combine two profiles with alignment array results from dynamic programming algorithm.
        /// The dynamic programming algorithm returns two arrays containing the alignment operations
        /// on the two profiles. This method applies the operation information in the two arrays to
        /// the two original profiles, and combine them into a new aligned profile.
        /// </summary>
        /// <param name="profileA">first profile</param>
        /// <param name="profileB">second profile</param>
        /// <param name="numberOfSequencesA">the number of sequences in the first profile</param>
        /// <param name="numberOfSequencesB">the number of sequences in the second profile</param>
        /// <param name="aAligned">aligned interger array generated by dynamic programming</param>
        /// <param name="bAligned">aligned interger array generated by dynamic programming</param>
        /// <param name="gapCode">the gap integer code defined in dynamic programming class</param>
        /// <param name="weights">the weights of two profiles</param>
        public static IProfiles GenerateProfiles(
            IProfiles profileA,
            IProfiles profileB,
            int numberOfSequencesA,
            int numberOfSequencesB,
            int[] aAligned,
            int[] bAligned,
            int gapCode,
            float[] weights)
        {
            if (aAligned.Length != bAligned.Length)
            {
                throw new ArgumentException("not aligned sequences");
            }
            IProfiles profiles = new Profiles(aAligned.Length, profileA.ColumnSize);

            MsaUtils.Normalize(weights);

            // a profile with gap only
            float[] gapProfile = new float[profiles.ColumnSize];
            gapProfile[gapProfile.Length - 1] = 1;

            for (int i = 0; i < aAligned.Length; ++i)
            {
                if (aAligned[i] == gapCode && bAligned[i] == gapCode)
                {
                    throw new Exception("Both positions are gap between two sets of sequences");
                }
                if (aAligned[i] == gapCode)
                {
                    for (int j = 0; j < profiles.ColumnSize; ++j)
                    {
                        profiles[i][j] = ((gapProfile[j] * numberOfSequencesA * weights[0]) + (profileB[bAligned[i]][j] * numberOfSequencesB * weights[1]))
                                         / (numberOfSequencesA + numberOfSequencesB);
                    }
                }
                else if (bAligned[i] == gapCode)
                {
                    for (int j = 0; j < profiles.ColumnSize; ++j)
                    {
                        profiles[i][j] = ((gapProfile[j] * numberOfSequencesA * weights[0]) + (profileA[aAligned[i]][j] * numberOfSequencesB * weights[1]))
                                         / (numberOfSequencesA + numberOfSequencesB);
                    }
                }
                else
                {
                    for (int j = 0; j < profiles.ColumnSize; ++j)
                    {
                        profiles[i][j] = ((profileA[aAligned[i]][j] * numberOfSequencesA * weights[0]) + (profileB[bAligned[i]][j] * numberOfSequencesB * weights[1]))
                                         / (numberOfSequencesA + numberOfSequencesB);
                    }
                }
            }
            return(profiles);
        }
Example #4
0
        /// <summary>
        /// Combine two profileAlignments into one if they are aligned already
        /// </summary>
        /// <param name="profileAlignmentA">first profile alignment</param>
        /// <param name="profileAlignmentB">second profile alignment</param>
        public static IProfileAlignment GenerateProfileAlignment(IProfileAlignment profileAlignmentA, IProfileAlignment profileAlignmentB)
        {
            IProfiles profileMatrix = Profiles.GenerateProfiles(
                profileAlignmentA.ProfilesMatrix, profileAlignmentB.ProfilesMatrix,
                profileAlignmentA.NumberOfSequences, profileAlignmentB.NumberOfSequences);

            IProfileAlignment profileAlignment = new ProfileAlignment();

            profileAlignment.NumberOfSequences = profileAlignmentA.NumberOfSequences + profileAlignmentB.NumberOfSequences;
            profileAlignment.ProfilesMatrix    = profileMatrix;

            return(profileAlignment);
        }
Example #5
0
        public void TestProfile()
        {
            ISequence templateSequence     = new Sequence(Alphabets.AmbiguousDNA, "ATGCSWRYKMBVHDN-");
            Dictionary <byte, int> itemSet = new Dictionary <byte, int>();

            for (int i = 0; i < templateSequence.Count; ++i)
            {
                itemSet.Add(templateSequence[i], i);

                if (char.IsLetter((char)templateSequence[i]))
                {
                    itemSet.Add((byte)char.ToLower((char)templateSequence[i]), i);
                }
            }
            Profiles.ItemSet = itemSet;

            ISequence seqA = new Sequence(Alphabets.DNA, "GGGAAAAATCAGATT");
            ISequence seqB = new Sequence(Alphabets.DNA, "GGGAATCAAAATCAG");

            List <ISequence> sequences = new List <ISequence>();

            sequences.Add(seqA);
            sequences.Add(seqB);

            // Test GenerateProfiles
            IProfiles profileA = Profiles.GenerateProfiles(sequences[0]);

            Assert.AreEqual(16, profileA.ColumnSize);
            Assert.AreEqual(sequences[0].Count, profileA.RowSize);

            // Test ProfileMatrix
            Assert.AreEqual(1, profileA.ProfilesMatrix[0][2]);
            Assert.AreEqual(0, profileA.ProfilesMatrix[0][3]);

            // Test ProfileAlignment
            IProfileAlignment profileAlignmentA = ProfileAlignment.GenerateProfileAlignment(sequences[0]);

            Assert.AreEqual(1, profileAlignmentA.ProfilesMatrix[0][2]);
            Assert.AreEqual(0, profileAlignmentA.ProfilesMatrix[0][3]);
            Assert.AreEqual(1, profileAlignmentA.NumberOfSequences);

            IProfileAlignment profileAlignmentB = ProfileAlignment.GenerateProfileAlignment(sequences);

            Assert.AreEqual(1, profileAlignmentB.ProfilesMatrix[0][2]);
            Assert.AreEqual(0, profileAlignmentB.ProfilesMatrix[0][3]);
            Assert.AreEqual(2, profileAlignmentB.NumberOfSequences);

            Assert.AreEqual(0.5, profileAlignmentB.ProfilesMatrix[5][0]);
            Assert.AreEqual(0.5, profileAlignmentB.ProfilesMatrix[5][1]);
            Assert.AreEqual(0, profileAlignmentB.ProfilesMatrix[5][2]);
        }
Example #6
0
        /// <summary>
        /// The profiles of two subsets is extracted from the current multiple alignment.
        /// Columns containing no residues, i.e. indels only, are discarded.
        ///
        /// This method is used in alignment refinement, when the guide tree is cut into two,
        /// the sequences (leaf nodes) are separated into two subsets. This method generates
        /// two profileAlignments for the two subtrees by extracting profiles of the two subsets
        /// of sequences.
        /// </summary>
        /// <param name="alignedSequences">a set of aligned sequences</param>
        /// <param name="sequenceIndicesA">the subset sequence indices of subtree A</param>
        /// <param name="sequenceIndicesB">the subset sequence indices of subtree B</param>
        /// <param name="allIndelPositions">the list of all-indel positions that have been removed when constructing</param>
        public static IProfileAlignment[] ProfileExtraction(List <ISequence> alignedSequences,
                                                            List <int> sequenceIndicesA, List <int> sequenceIndicesB,
                                                            out List <int>[] allIndelPositions)
        {
            allIndelPositions = new List <int> [2];
            IProfiles         profileA          = Profiles.GenerateProfiles(alignedSequences, sequenceIndicesA, out allIndelPositions[0]);
            IProfiles         profileB          = Profiles.GenerateProfiles(alignedSequences, sequenceIndicesB, out allIndelPositions[1]);
            IProfileAlignment profileAlignmentA = new ProfileAlignment();
            IProfileAlignment profileAlignmentB = new ProfileAlignment();

            profileAlignmentA.ProfilesMatrix    = profileA;
            profileAlignmentB.ProfilesMatrix    = profileB;
            profileAlignmentA.NumberOfSequences = sequenceIndicesA.Count;
            profileAlignmentB.NumberOfSequences = sequenceIndicesB.Count;

            return(new IProfileAlignment[2] {
                profileAlignmentA, profileAlignmentB
            });
        }
Example #7
0
        /// <summary>
        /// Combine two profileAlignments with alignment operation array from dynamic programming.
        /// The dynamic programming algorithm returns two arrays containing the alignment operations
        /// on the two profiles. This method applies the operation information in the two arrays to
        /// the two original profiles, and combine them into a new aligned profile, and put into the
        /// newly generated profileAlignment.
        /// </summary>
        /// <param name="profileAlignmentA">first profile alignment</param>
        /// <param name="profileAlignmentB">second profile alignment</param>
        /// <param name="aAligned">aligned interger array generated by dynamic programming</param>
        /// <param name="bAligned">aligned interger array generated by dynamic programming</param>
        /// <param name="gapCode">the gap integer code defined in dynamic programming class</param>
        public static IProfileAlignment GenerateProfileAlignment(
            IProfileAlignment profileAlignmentA,
            IProfileAlignment profileAlignmentB,
            int[] aAligned,
            int[] bAligned,
            int gapCode)
        {
            IProfiles profileMatrix = Profiles.GenerateProfiles(
                profileAlignmentA.ProfilesMatrix, profileAlignmentB.ProfilesMatrix,
                profileAlignmentA.NumberOfSequences, profileAlignmentB.NumberOfSequences,
                aAligned, bAligned, gapCode);

            IProfileAlignment profileAlignment = new ProfileAlignment();

            profileAlignment.NumberOfSequences = profileAlignmentA.NumberOfSequences +
                                                 profileAlignmentB.NumberOfSequences;
            profileAlignment.ProfilesMatrix = profileMatrix;

            return(profileAlignment);
        }
Example #8
0
        /// <summary>
        /// Combine two profiles into one.
        /// The frequencies in the two profiles are weighted by the number of sequences.
        /// The new frequencies are defined as:
        /// (frequencyA * numberOfSequenceA + frequencyB * numberOfSequenceB) / (numberOfSequenceA + numberOfSequenceB)
        /// </summary>
        /// <param name="profileA">first profile alignment</param>
        /// <param name="profileB">second profile alignment</param>
        /// <param name="numberOfSequencesA">the number of sequences in the first profile</param>
        /// <param name="numberOfSequencesB">the number of sequences in the second profile</param>
        public static IProfiles GenerateProfiles(IProfiles profileA, IProfiles profileB, int numberOfSequencesA, int numberOfSequencesB)
        {
            if (profileA.RowSize != profileB.RowSize ||
                profileA.ColumnSize != profileB.ColumnSize)
            {
                throw new Exception("different profiles sizes");
            }

            IProfiles profiles;

            profiles = new Profiles(profileA);

            for (int i = 0; i < profiles.RowSize; ++i)
            {
                for (int j = 0; j < profiles.ColumnSize; ++j)
                {
                    profiles[i][j] = (profileA[i][j] * numberOfSequencesA + profileB[i][j] * numberOfSequencesB)
                                     / (numberOfSequencesA + numberOfSequencesB);
                }
            }
            return(profiles);
        }
Example #9
0
 public static void Assign(IConfig config, ISettings settings, IThemes themes, IBackgroundMusic backgroundMusic,
                           IDrawing draw, IGraphics graphics, IFonts fonts, ILanguage language, IGame game, IProfiles profiles, IRecording record,
                           ISongs songs, IVideo video, ISound sound, ICover cover, IDataBase dataBase, IControllers controller, IPlaylist playlist)
 {
     Config          = config;
     Settings        = settings;
     Themes          = themes;
     BackgroundMusic = backgroundMusic;
     Drawing         = draw;
     Graphics        = graphics;
     Fonts           = fonts;
     Language        = language;
     Game            = game;
     Profiles        = profiles;
     Record          = record;
     Songs           = songs;
     Video           = video;
     Sound           = sound;
     Cover           = cover;
     DataBase        = dataBase;
     Controller      = controller;
     Playlist        = playlist;
 }
Example #10
0
 public GetWorkerByTag(IStat _statRepo, IProfiles _profileRepo, IGRUDWorker _workerRepo)
 {
     statRepo    = _statRepo;
     profileRepo = _profileRepo;
     workerRepo  = _workerRepo;
 }
Example #11
0
        /// <summary>
        /// Combine two profiles into one.
        /// The frequencies in the two profiles are weighted by the number of sequences.
        /// The new frequencies are defined as:
        /// (frequencyA * numberOfSequenceA + frequencyB * numberOfSequenceB) / (numberOfSequenceA + numberOfSequenceB)
        /// </summary>
        /// <param name="profileA">first profile alignment</param>
        /// <param name="profileB">second profile alignment</param>
        /// <param name="numberOfSequencesA">the number of sequences in the first profile</param>
        /// <param name="numberOfSequencesB">the number of sequences in the second profile</param>
        public static IProfiles GenerateProfiles(IProfiles profileA, IProfiles profileB, int numberOfSequencesA, int numberOfSequencesB)
        {
            if (profileA.RowSize != profileB.RowSize
                || profileA.ColumnSize != profileB.ColumnSize)
            {
                throw new Exception("different profiles sizes");
            }

            IProfiles profiles;

            profiles = new Profiles(profileA);

            for (int i = 0; i < profiles.RowSize; ++i)
            {
                for (int j = 0; j < profiles.ColumnSize; ++j)
                {
                    profiles[i][j] = (profileA[i][j] * numberOfSequencesA + profileB[i][j] * numberOfSequencesB)
                                                / (numberOfSequencesA + numberOfSequencesB);
                }
            }
            return profiles;
        }
Example #12
0
        /// <summary>
        /// Combine two profiles with alignment array results from dynamic programming algorithm.
        /// The dynamic programming algorithm returns two arrays containing the alignment operations
        /// on the two profiles. This method applies the operation information in the two arrays to 
        /// the two original profiles, and combine them into a new aligned profile.
        /// </summary>
        /// <param name="profileA">first profile</param>
        /// <param name="profileB">second profile</param>
        /// <param name="numberOfSequencesA">the number of sequences in the first profile</param>
        /// <param name="numberOfSequencesB">the number of sequences in the second profile</param>
        /// <param name="aAligned">aligned interger array generated by dynamic programming</param>
        /// <param name="bAligned">aligned interger array generated by dynamic programming</param>
        /// <param name="gapCode">the gap integer code defined in dynamic programming class</param>
        /// <param name="weights">the weights of two profiles</param>
        public static IProfiles GenerateProfiles(
                IProfiles profileA,
                IProfiles profileB,
                int numberOfSequencesA,
                int numberOfSequencesB,
                int[] aAligned,
                int[] bAligned,
                int gapCode,
                float[] weights)
        {
            if (aAligned.Length != bAligned.Length)
            {
                throw new ArgumentException("not aligned sequences");
            }
            IProfiles profiles = new Profiles(aAligned.Length, profileA.ColumnSize);

            MsaUtils.Normalize(weights);

            // a profile with gap only
            float[] gapProfile = new float[profiles.ColumnSize];
            gapProfile[gapProfile.Length - 1] = 1;

            for (int i = 0; i < aAligned.Length; ++i)
            {
                if (aAligned[i] == gapCode && bAligned[i] == gapCode)
                {
                    throw new Exception("Both positions are gap between two sets of sequences");
                }
                if (aAligned[i] == gapCode)
                {
                    for (int j = 0; j < profiles.ColumnSize; ++j)
                    {
                        profiles[i][j] = ((gapProfile[j] * numberOfSequencesA * weights[0]) + (profileB[bAligned[i]][j] * numberOfSequencesB * weights[1]))
                                                / (numberOfSequencesA + numberOfSequencesB);
                    }
                }
                else if (bAligned[i] == gapCode)
                {
                    for (int j = 0; j < profiles.ColumnSize; ++j)
                    {
                        profiles[i][j] = ((gapProfile[j] * numberOfSequencesA * weights[0]) + (profileA[aAligned[i]][j] * numberOfSequencesB * weights[1]))
                                                / (numberOfSequencesA + numberOfSequencesB);
                    }
                }
                else
                {
                    for (int j = 0; j < profiles.ColumnSize; ++j)
                    {
                        profiles[i][j] = ((profileA[aAligned[i]][j] * numberOfSequencesA * weights[0]) + (profileB[bAligned[i]][j] * numberOfSequencesB * weights[1]))
                                                / (numberOfSequencesA + numberOfSequencesB);
                    }
                }
            }
            return profiles;
        }
Example #13
0
        /// <param name='operations'>
        /// Reference to the DataExportSales.IProfiles.
        /// </param>
        /// <param name='organizationId'>
        /// Required. Organization Id
        /// </param>
        /// <param name='status'>
        /// Optional. Include Profile Status
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public static async Task <object> GetProfilesByOrganizationIdAsync(this IProfiles operations, string organizationId, bool?status = null, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Microsoft.Rest.HttpOperationResponse <object> result = await operations.GetProfilesByOrganizationIdWithOperationResponseAsync(organizationId, status, cancellationToken).ConfigureAwait(false);

            return(result.Body);
        }
Example #14
0
 /// <summary>
 /// Copy from an existing profiles
 /// </summary>
 /// <param name="p">an existing profile class</param>
 public Profiles(IProfiles p)
 {
     _rowSize = p.RowSize;
     _colSize = p.ColumnSize;
     _profilesMatrix = p.ProfilesMatrix;
 }
Example #15
0
        /// <param name='operations'>
        /// Reference to the DataExportSales.IProfiles.
        /// </param>
        /// <param name='registration'>
        /// Required. Description of the new Profile to be created
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public static async Task <object> ValidateBeforeProfileCreationAsync(this IProfiles operations, ProfileDescriptionBase registration, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Microsoft.Rest.HttpOperationResponse <object> result = await operations.ValidateBeforeProfileCreationWithOperationResponseAsync(registration, cancellationToken).ConfigureAwait(false);

            return(result.Body);
        }
Example #16
0
        /// <param name='operations'>
        /// Reference to the DataExportSales.IProfiles.
        /// </param>
        /// <param name='id'>
        /// Required. Profile Id
        /// </param>
        /// <param name='updatedProfile'>
        /// Required. Description of updates to the Profile
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public static async Task <object> UpdateProfileAsync(this IProfiles operations, string id, ProfileDetailsDTO updatedProfile, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Microsoft.Rest.HttpOperationResponse <object> result = await operations.UpdateProfileWithOperationResponseAsync(id, updatedProfile, cancellationToken).ConfigureAwait(false);

            return(result.Body);
        }
Example #17
0
 /// <summary>
 /// Copy from an existing profiles
 /// </summary>
 /// <param name="p">an existing profile class</param>
 public Profiles(IProfiles p)
 {
     _rowSize        = p.RowSize;
     _colSize        = p.ColumnSize;
     _profilesMatrix = p.ProfilesMatrix;
 }
Example #18
0
 public ProfilesController(IProfiles process, IProfilesMenu processProfileMenu)
 {
     _process            = process;
     _processProfileMenu = processProfileMenu;
 }
 public ProfileController(IProfiles profile)
 {
     profileRepo = profile;
 }
Example #20
0
 public LoginController(IProfiles context)
 {
     _context = context;
 }
Example #21
0
        /// <param name='operations'>
        /// Reference to the DataExportSales.IProfiles.
        /// </param>
        /// <param name='id'>
        /// Required. Profile Id
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public static async Task <object> ActivateDataAsync(this IProfiles operations, string id, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            Microsoft.Rest.HttpOperationResponse <object> result = await operations.ActivateDataWithOperationResponseAsync(id, cancellationToken).ConfigureAwait(false);

            return(result.Body);
        }
Example #22
0
        public override void Initialize(string name, NameValueCollection config)
        {
            // Initialize values from web.config.
            if (config == null)
                throw new ArgumentNullException("config");

            if (name == null || name.Length == 0)
                name = "JsProfileProvider";

            if (String.IsNullOrEmpty(config["description"])) {
                config.Remove("description");
                config.Add("description", "Nhibernate Profile provider");
            }

            // Initialize the abstract base class.
            base.Initialize(name, config);

            _applicationName = GetConfigValue(config["applicationName"], System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath);
            WriteExceptionsToEventLog = Convert.ToBoolean(GetConfigValue(config["writeExceptionsToEventLog"], "true"));
            users = WindsorBootStrapper.Container.Kernel.Resolve<IUsers>();
            profiles = WindsorBootStrapper.Container.Kernel.Resolve<IProfiles>();
        }
 public RegisterController(IProfiles context)
 {
     _context = context;
 }