private void InitNames() { if (_alternativeNames != null) { return; } _alternativeNames = new List <ProteinMetadata>(); using (var proteomeDb = OpenProteomeDb()) using (var session = proteomeDb.OpenSession()) { var protein = GetEntity(session); foreach (var name in protein.Names) { if (name.Name == Name) { continue; } if (Name == null && name.IsPrimary) { _proteinMetadata = name.GetProteinMetadata(); } else { _alternativeNames.Add(name.GetProteinMetadata()); } } } }
internal Protein(ProteomeDbPath proteomeDbPath, DbProtein protein, IEnumerable <DbProteinName> proteinNames) : this(proteomeDbPath, protein, (DbProteinName)null) { _proteinMetadata = ProteinMetadata.EMPTY; _alternativeNames = new List <ProteinMetadata>(); foreach (DbProteinName proteinName in proteinNames) { if (proteinName.IsPrimary) { _proteinMetadata = proteinName.GetProteinMetadata(); } else { _alternativeNames.Add(proteinName.GetProteinMetadata()); // copies the ProteinMetadata info } } }
internal Protein(ProteomeDbPath proteomeDb, DbProtein protein, DbProteinName primaryName) : base(proteomeDb, protein) { Sequence = protein.Sequence; if (primaryName != null) { _proteinMetadata = primaryName.GetProteinMetadata(); if (primaryName.Protein != null) { // grab the alternative names now, rather than going back to the db later _alternativeNames = new List <ProteinMetadata>(); foreach (var name in primaryName.Protein.Names) { if (!name.IsPrimary) { _alternativeNames.Add(name.GetProteinMetadata()); } } } } }
public static string TextForMatchTypes(this ProteinMetadata p, ProteinMatchTypes types) { if (types.IsSingleton(ProteinMatchType.sequence)) { return(null); } var results = new List <string>(); if (types.Contains(ProteinMatchType.name)) { results.Add(p.Name ?? String.Empty); } if (types.Contains(ProteinMatchType.accession)) { results.Add(p.Accession ?? String.Empty); } if (types.Contains(ProteinMatchType.preferredName)) { results.Add(p.PreferredName ?? String.Empty); } if (types.Contains(ProteinMatchType.gene)) { results.Add(p.Gene ?? String.Empty); } if (types.Contains(ProteinMatchType.species)) { results.Add(p.Species ?? String.Empty); } if (types.Contains(ProteinMatchType.description)) // put this last, as it likely contains the others { results.Add(p.Description ?? String.Empty); } if (results.Count > 0) { return(String.Join(@" ", results)); } return(null); }
private ProteinMetadata _proteinMetadata; // name, description, accession, gene etc internal Protein(ProteomeDbPath proteomeDb, DbProtein protein) : this(proteomeDb, protein, (DbProteinName)null) { _proteinMetadata = ProteinMetadata.EMPTY; }
private static bool Matches(ProteinMetadata proteinMetadata, ProteinMatchType matchType, string ltext) { return(ContainsLowerCase(proteinMetadata.TextForMatchTypes(ProteinMatchTypes.Singleton(matchType)), ltext)); }