Exemple #1
0
        int IComparable.CompareTo(Object obj)
        {
            PSM temp = (PSM)obj;

            if (string.Compare(this.Title, temp.Title) < 0)
            {
                return(-1);
            }
            else if (string.Compare(this.Title, temp.Title) > 0)
            {
                return(1);
            }
            return(0);
            //int scan_number = int.Parse(this.Title.Split('.')[1]);
            //int scan_number2 = int.Parse(temp.Title.Split('.')[1]);
            //if (scan_number < scan_number2)
            //    return -1;
            //else if (scan_number > scan_number2)
            //    return 1;
            //int pParse_number = int.Parse(this.Title.Split('.')[4]);
            //int pParse_number2 = int.Parse(temp.Title.Split('.')[4]);
            //if (pParse_number < pParse_number2)
            //    return -1;
            //else if (pParse_number > pParse_number2)
            //    return 1;
            //return 0;
        }
Exemple #2
0
        public static PSM getPSM_BySpectra(Spectra spec)
        {
            PSM psm = new PSM(0, spec.Title, "", "", 0.0, spec.Pepmass, 0.0, 0.0, 0.0, 0.0, ' ', "0", true, "", 0);

            psm.Charge       = spec.Charge;
            psm.Spectra_mass = spec.Pepmass * spec.Charge - Config_Help.massZI * (spec.Charge - 1);
            return(psm);
        }
Exemple #3
0
        public ObservableCollection <PSM> filter_bySQ(PSM psm, ObservableCollection <PSM> all_psms)
        {
            ObservableCollection <PSM> psms = new ObservableCollection <PSM>();
            string ss = psm.Sq;

            for (int i = 0; i < all_psms.Count; ++i)
            {
                if (ss == all_psms[i].Sq)
                {
                    psms.Add(all_psms[i]);
                }
            }
            return(psms);
        }
Exemple #4
0
        public ObservableCollection <PSM> filter_byPeptide(PSM psm, ObservableCollection <PSM> all_psms)
        {
            ObservableCollection <PSM> psms = new ObservableCollection <PSM>();
            string ss = psm.Sq + "@" + psm.Mod_sites;

            for (int i = 0; i < all_psms.Count; ++i)
            {
                string tmp_ss = all_psms[i].Sq + "@" + all_psms[i].Mod_sites;
                if (ss == tmp_ss)
                {
                    psms.Add(all_psms[i]);
                }
            }
            return(psms);
        }
Exemple #5
0
        private void display_btn(object sender, RoutedEventArgs e)
        {
            ObservableCollection <PSM> all_psms = this.mainW.display_psms;

            filter_btn(null, null);
            ObservableCollection <PSM> new_psms = this.mainW.display_psms;

            this.mainW.display_psms      = all_psms;
            this.mainW.data.ItemsSource  = all_psms;
            this.mainW.display_size.Text = all_psms.Count.ToString();
            if (new_psms.Count == 0)
            {
                return;
            }
            PSM selected_psm = new_psms[0];

            this.mainW.data.SelectedItem = selected_psm;
            object item = this.mainW.data.SelectedItem;

            if (item != null)
            {
                this.mainW.data.ScrollIntoView(item);
            }
        }
Exemple #6
0
 public static void update_MS2_ratio(ObservableCollection <Protein> proteins, ObservableCollection <PSM> psms)
 {
     for (int i = 0; i < proteins.Count; ++i)
     {
         List <double> ratios    = new List <double>();
         List <double> a1_ratios = new List <double>();
         System.Collections.Hashtable sq_hash    = new System.Collections.Hashtable();
         System.Collections.Hashtable sq_hash_a1 = new System.Collections.Hashtable();
         List <int> psm_index = proteins[i].psm_index;
         for (int j = 0; j < psm_index.Count; ++j)
         {
             int index   = psm_index[j];
             PSM one_psm = psms[index];
             if (sq_hash[one_psm.Sq] == null)
             {
                 List <double> rr = new List <double>();
                 if (one_psm.Ms2_ratio != 0.0)
                 {
                     rr.Add(Math.Log10(one_psm.Ms2_ratio) / Math.Log10(2.0));
                 }
                 sq_hash[one_psm.Sq] = rr;
                 rr = new List <double>();
                 if (one_psm.Ms2_ratio_a1 != 0.0)
                 {
                     rr.Add(Math.Log10(one_psm.Ms2_ratio_a1) / Math.Log10(2.0));
                 }
                 sq_hash_a1[one_psm.Sq] = rr;
             }
             else
             {
                 if (one_psm.Ms2_ratio != 0.0)
                 {
                     List <double> rr = sq_hash[one_psm.Sq] as List <double>;
                     rr.Add(Math.Log10(one_psm.Ms2_ratio) / Math.Log10(2.0));
                     sq_hash[one_psm.Sq] = rr;
                 }
                 if (one_psm.Ms2_ratio_a1 != 0.0)
                 {
                     List <double> rr = sq_hash_a1[one_psm.Sq] as List <double>;
                     rr.Add(Math.Log10(one_psm.Ms2_ratio_a1) / Math.Log10(2.0));
                     sq_hash_a1[one_psm.Sq] = rr;
                 }
             }
         }
         foreach (string key in sq_hash.Keys)
         {
             List <double> rr = sq_hash[key] as List <double>;
             if (rr.Count > 0)
             {
                 rr.Sort();
                 if (rr.Count % 2 != 0)
                 {
                     ratios.Add(rr[rr.Count / 2]);
                 }
                 else
                 {
                     ratios.Add((rr[rr.Count / 2] + rr[rr.Count / 2 - 1]) / 2);
                 }
             }
         }
         foreach (string key in sq_hash_a1.Keys)
         {
             List <double> rr = sq_hash_a1[key] as List <double>;
             if (rr.Count > 0)
             {
                 rr.Sort();
                 if (rr.Count % 2 != 0)
                 {
                     a1_ratios.Add(rr[rr.Count / 2]);
                 }
                 else
                 {
                     a1_ratios.Add((rr[rr.Count / 2] + rr[rr.Count / 2 - 1]) / 2);
                 }
             }
         }
         if (ratios.Count > 0)
         {
             ratios.Sort();
             if (ratios.Count % 2 != 0)
             {
                 proteins[i].MS2_Ratio = Math.Pow(2.0, ratios[ratios.Count / 2]);
             }
             else
             {
                 proteins[i].MS2_Ratio = Math.Pow(2.0, (ratios[ratios.Count / 2] + ratios[ratios.Count / 2 - 1]) / 2);
             }
         }
         if (a1_ratios.Count > 0)
         {
             a1_ratios.Sort();
             if (a1_ratios.Count % 2 != 0)
             {
                 proteins[i].MS2_Ratio_a1 = Math.Pow(2.0, a1_ratios[a1_ratios.Count / 2]);
             }
             else
             {
                 proteins[i].MS2_Ratio_a1 = Math.Pow(2.0, (a1_ratios[a1_ratios.Count / 2] + a1_ratios[a1_ratios.Count / 2 - 1]) / 2);
             }
         }
     }
 }
Exemple #7
0
        public int Compare(object x, object y)
        {
            PSM psm1 = x as PSM;
            PSM psm2 = y as PSM;

            //sort int
            if (header_name == "#")
            {
                int psm1_ID = psm1.Id;
                int psm2_ID = psm2.Id;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_ID > psm2_ID)
                    {
                        return(1);
                    }
                    else if (psm1_ID < psm2_ID)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_ID > psm2_ID)
                    {
                        return(-1);
                    }
                    else if (psm1_ID < psm2_ID)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Spectrum")
            {
                string psm1_title = psm1.Title;
                string psm2_title = psm2.Title;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (string.Compare(psm1_title, psm2_title) > 0)
                    {
                        return(1);
                    }
                    else if (string.Compare(psm1_title, psm2_title) < 0)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (string.Compare(psm1_title, psm2_title) > 0)
                    {
                        return(-1);
                    }
                    else if (string.Compare(psm1_title, psm2_title) < 0)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Charge")
            {
                int psm1_charge = psm1.Charge;
                int psm2_charge = psm2.Charge;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_charge > psm2_charge)
                    {
                        return(1);
                    }
                    else if (psm1_charge < psm2_charge)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_charge > psm2_charge)
                    {
                        return(-1);
                    }
                    else if (psm1_charge < psm2_charge)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Spectrum mass")
            {
                double psm1_mass = psm1.Spectra_mass;
                double psm2_mass = psm2.Spectra_mass;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_mass > psm2_mass)
                    {
                        return(1);
                    }
                    else if (psm1_mass < psm2_mass)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_mass > psm2_mass)
                    {
                        return(-1);
                    }
                    else if (psm1_mass < psm2_mass)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Sequence")
            {
                string psm1_sq = psm1.Sq;
                string psm2_sq = psm2.Sq;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (string.Compare(psm1_sq, psm2_sq) > 0)
                    {
                        return(1);
                    }
                    else if (string.Compare(psm1_sq, psm2_sq) < 0)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (string.Compare(psm1_sq, psm2_sq) > 0)
                    {
                        return(-1);
                    }
                    else if (string.Compare(psm1_sq, psm2_sq) < 0)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Mod_Sites")
            {
                string psm1_modsites = psm1.Mod_sites;
                string psm2_modsites = psm2.Mod_sites;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (string.Compare(psm1_modsites, psm2_modsites) > 0)
                    {
                        return(1);
                    }
                    else if (string.Compare(psm1_modsites, psm2_modsites) < 0)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (string.Compare(psm1_modsites, psm2_modsites) > 0)
                    {
                        return(-1);
                    }
                    else if (string.Compare(psm1_modsites, psm2_modsites) < 0)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Specific")
            {
                char psm1_specific_flag = psm1.Specific_flag;
                char psm2_specific_flag = psm2.Specific_flag;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_specific_flag > psm2_specific_flag)
                    {
                        return(1);
                    }
                    else if (psm1_specific_flag < psm2_specific_flag)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_specific_flag > psm2_specific_flag)
                    {
                        return(-1);
                    }
                    else if (psm1_specific_flag < psm2_specific_flag)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Missed_Cleavage")
            {
                int psm1_missed_number = psm1.Missed_cleavage_number;
                int psm2_missed_number = psm2.Missed_cleavage_number;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_missed_number > psm2_missed_number)
                    {
                        return(1);
                    }
                    else if (psm1_missed_number < psm2_missed_number)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_missed_number > psm2_missed_number)
                    {
                        return(-1);
                    }
                    else if (psm1_missed_number < psm2_missed_number)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Score")
            {
                double psm1_score = psm1.Score;
                double psm2_score = psm2.Score;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_score > psm2_score)
                    {
                        return(1);
                    }
                    else if (psm1_score < psm2_score)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_score > psm2_score)
                    {
                        return(-1);
                    }
                    else if (psm1_score < psm2_score)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Ratio")
            {
                double psm1_ratio = psm1.Ratio;
                double psm2_ratio = psm2.Ratio;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_ratio > psm2_ratio)
                    {
                        return(1);
                    }
                    else if (psm1_ratio < psm2_ratio)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_ratio > psm2_ratio)
                    {
                        return(-1);
                    }
                    else if (psm1_ratio < psm2_ratio)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Sigma")
            {
                double psm1_sigma = psm1.Sigma;
                double psm2_sigma = psm2.Sigma;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_sigma > psm2_sigma)
                    {
                        return(1);
                    }
                    else if (psm1_sigma < psm2_sigma)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_sigma > psm2_sigma)
                    {
                        return(-1);
                    }
                    else if (psm1_sigma < psm2_sigma)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "AC")
            {
                string psm1_ac = psm1.AC;
                string psm2_ac = psm2.AC;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (string.Compare(psm1_ac, psm2_ac) > 0)
                    {
                        return(1);
                    }
                    else if (string.Compare(psm1_ac, psm2_ac) < 0)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (string.Compare(psm1_ac, psm2_ac) > 0)
                    {
                        return(-1);
                    }
                    else if (string.Compare(psm1_ac, psm2_ac) < 0)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Target_Decoy")
            {
                string psm1_is_target_flag = psm1.Is_target_flag.ToString();
                string psm2_is_target_flag = psm2.Is_target_flag.ToString();
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (string.Compare(psm1_is_target_flag, psm2_is_target_flag) > 0)
                    {
                        return(1);
                    }
                    else if (string.Compare(psm1_is_target_flag, psm2_is_target_flag) < 0)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (string.Compare(psm1_is_target_flag, psm2_is_target_flag) > 0)
                    {
                        return(-1);
                    }
                    else if (string.Compare(psm1_is_target_flag, psm2_is_target_flag) < 0)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Label_Name")
            {
                string psm1_N15 = psm1.Pep_flag;
                string psm2_N15 = psm2.Pep_flag;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (string.Compare(psm1_N15, psm2_N15) > 0)
                    {
                        return(1);
                    }
                    else if (string.Compare(psm1_N15, psm2_N15) < 0)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (string.Compare(psm1_N15, psm2_N15) > 0)
                    {
                        return(-1);
                    }
                    else if (string.Compare(psm1_N15, psm2_N15) < 0)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Detla_Mass (Da)")
            {
                double psm1_da_mass = psm1.Delta_mass;
                double psm2_da_mass = psm2.Delta_mass;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_da_mass > psm2_da_mass)
                    {
                        return(1);
                    }
                    else if (psm1_da_mass < psm2_da_mass)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_da_mass > psm2_da_mass)
                    {
                        return(-1);
                    }
                    else if (psm1_da_mass < psm2_da_mass)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "Detla_Mass (PPM)")
            {
                double psm1_ppm_mass = psm1.Delta_mass_PPM;
                double psm2_ppm_mass = psm2.Delta_mass_PPM;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_ppm_mass > psm2_ppm_mass)
                    {
                        return(1);
                    }
                    else if (psm1_ppm_mass < psm2_ppm_mass)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_ppm_mass > psm2_ppm_mass)
                    {
                        return(-1);
                    }
                    else if (psm1_ppm_mass < psm2_ppm_mass)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "MS2 Ratio")
            {
                double psm1_ms2_ratio = psm1.Ms2_ratio;
                double psm2_ms2_ratio = psm2.Ms2_ratio;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_ms2_ratio > psm2_ms2_ratio)
                    {
                        return(1);
                    }
                    else if (psm1_ms2_ratio < psm2_ms2_ratio)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_ms2_ratio > psm2_ms2_ratio)
                    {
                        return(-1);
                    }
                    else if (psm1_ms2_ratio < psm2_ms2_ratio)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else if (header_name == "MS2 Ratio a1")
            {
                double psm1_ms2_ratio = psm1.Ms2_ratio_a1;
                double psm2_ms2_ratio = psm2.Ms2_ratio_a1;
                if (this.direction == ListSortDirection.Ascending)
                {
                    if (psm1_ms2_ratio > psm2_ms2_ratio)
                    {
                        return(1);
                    }
                    else if (psm1_ms2_ratio < psm2_ms2_ratio)
                    {
                        return(-1);
                    }
                    return(0);
                }
                else
                {
                    if (psm1_ms2_ratio > psm2_ms2_ratio)
                    {
                        return(-1);
                    }
                    else if (psm1_ms2_ratio < psm2_ms2_ratio)
                    {
                        return(1);
                    }
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }