예제 #1
0
 public TaxonomyItem(int taxId, int parentTaxId, TaxonomyRank rank, int divisionId, int geneticCodeId,
                     int mitoGeneticCodeId)
 {
     this.TaxId             = taxId;
     this.parentTaxId       = parentTaxId;
     this.Rank              = rank;
     this.divisionId        = divisionId;
     this.geneticCodeId     = geneticCodeId;
     this.mitoGeneticCodeId = mitoGeneticCodeId;
 }
예제 #2
0
 public static TaxonomyItem[] GetItemsOfRank(TaxonomyRank rank)
 {
     List<TaxonomyItem> x = new List<TaxonomyItem>();
     foreach (TaxonomyItem ti in taxonomyItems){
         if (ti.Rank == rank){
             x.Add(ti);
         }
     }
     return x.ToArray();
 }
예제 #3
0
        public TaxonomyItem(int taxId, int parentTaxId, TaxonomyRank rank, int divisionId, int geneticCodeId,
			int mitoGeneticCodeId)
        {
            this.TaxId = taxId;
            this.parentTaxId = parentTaxId;
            this.Rank = rank;
            this.divisionId = divisionId;
            this.geneticCodeId = geneticCodeId;
            this.mitoGeneticCodeId = mitoGeneticCodeId;
        }
예제 #4
0
 public TaxonomyItem GetParentOfRank(TaxonomyRank rank1)
 {
     if (rank1 == Rank){
         return this;
     }
     if (!TaxonomyItems.taxId2Item.ContainsKey(parentTaxId)){
         return null;
     }
     TaxonomyItem parent = TaxonomyItems.taxId2Item[parentTaxId];
     return parent.GetParentOfRank(rank1);
 }
예제 #5
0
 public static string GetTaxonomyIdOfRank(string taxonomyId, TaxonomyRank rank)
 {
     int id;
     if (!int.TryParse(taxonomyId, out id)){
         return taxonomyId;
     }
     if (!taxId2Item.ContainsKey(id)){
         return taxonomyId;
     }
     TaxonomyItem item = taxId2Item[id];
     return "" + item.TaxId;
 }
예제 #6
0
        public static TaxonomyItem[] GetItemsOfRank(TaxonomyRank rank)
        {
            List <TaxonomyItem> x = new List <TaxonomyItem>();

            foreach (TaxonomyItem ti in taxonomyItems)
            {
                if (ti.Rank == rank)
                {
                    x.Add(ti);
                }
            }
            return(x.ToArray());
        }
예제 #7
0
        public TaxonomyItem GetParentOfRank(TaxonomyItems taxonomyItems, TaxonomyRank rank1)
        {
            if (rank1 == Rank)
            {
                return(this);
            }
            if (!taxonomyItems.taxId2Item.ContainsKey(parentTaxId))
            {
                return(null);
            }
            TaxonomyItem parent = taxonomyItems.taxId2Item[parentTaxId];

            return(parent.GetParentOfRank(taxonomyItems, rank1));
        }
예제 #8
0
        public static string GetTaxonomyIdOfRank(string taxonomyId, TaxonomyRank rank)
        {
            int id;

            if (!int.TryParse(taxonomyId, out id))
            {
                return(taxonomyId);
            }
            if (!taxId2Item.ContainsKey(id))
            {
                return(taxonomyId);
            }
            TaxonomyItem item = taxId2Item[id];

            return("" + item.TaxId);
        }
예제 #9
0
        public static TaxonomyItem[] Init()
        {
            StreamReader        reader = GetReader(Resources.nodes_dmp);
            string              line;
            List <TaxonomyItem> result = new List <TaxonomyItem>();
            Dictionary <TaxonomyRank, List <TaxonomyItem> > counts = new Dictionary <TaxonomyRank, List <TaxonomyItem> >();

            taxId2Item = new Dictionary <int, TaxonomyItem>();
            name2Item  = new Dictionary <string, TaxonomyItem>();
            while ((line = reader.ReadLine()) != null)
            {
                string[]     w                 = line.Split(new[] { "\t|\t" }, StringSplitOptions.None);
                int          taxId             = int.Parse(w[0]);
                int          parentTaxId       = int.Parse(w[1]);
                TaxonomyRank rank              = GetRank(w[2]);
                int          divisionId        = int.Parse(w[4]);
                int          geneticCodeId     = int.Parse(w[6]);
                int          mitoGeneticCodeId = int.Parse(w[8]);
                TaxonomyItem ti                = new TaxonomyItem(taxId, parentTaxId, rank, divisionId, geneticCodeId, mitoGeneticCodeId);
                result.Add(ti);
                if (!counts.ContainsKey(rank))
                {
                    counts.Add(rank, new List <TaxonomyItem>());
                }
                counts[rank].Add(ti);
                taxId2Item.Add(taxId, ti);
            }
            reader = GetReader(Resources.names_dmp);
            while ((line = reader.ReadLine()) != null)
            {
                string[]         w        = line.Split(new[] { "\t|\t" }, StringSplitOptions.None);
                int              taxId    = int.Parse(w[0]);
                string           name     = w[1];
                TaxonomyNameType nameType = GetNameType(w[3].Substring(0, w[3].Length - 2));
                TaxonomyItem     item     = taxId2Item[taxId];
                item.AddName(name, nameType);
                string low = name.ToLower();
                if (!name2Item.ContainsKey(low))
                {
                    name2Item.Add(low, item);
                }
            }
            return(result.ToArray());
        }