public static DefaultAccessNumberParser GetInstance() { if (parser == null) { parser = new DefaultAccessNumberParser(); } return parser; }
public static DefaultAccessNumberParser GetInstance() { if (parser == null) { parser = new DefaultAccessNumberParser(); } return(parser); }
public string GetValue(string obj) { string result; if (!parser.TryParse(obj, out result)) { result = DefaultAccessNumberParser.GetInstance().GetValue(obj); } return(result); }
private static void InitParsers() { ParserFormatList lstFormat = ParserFormatList.ReadFromOptionFile(SECTION_NAME); parsers = GetParsers(lstFormat); autoParser = parsers.Find(m => m.FormatName.Equals(AutoAccessNumberParser.FORMAT_NAME)); if (autoParser == null) { autoParser = DefaultAccessNumberParser.GetInstance(); } }
public string GetValue(string name) { foreach (IAccessNumberParser parser in parsers) { string result; if (parser.TryParse(name, out result)) { return(result); } } return(DefaultAccessNumberParser.GetInstance().GetValue(name)); }
public static List <IAccessNumberParser> GetParsers(ParserFormatList lstFormat) { List <IAccessNumberParser> result = new List <IAccessNumberParser>(); if (null != lstFormat && lstFormat.Count > 0) { List <IAccessNumberParser> parsers = lstFormat.ConvertAll(m => (IAccessNumberParser) new AccessNumberParser(m)); parsers.ForEach(p => result.Add(new NoExceptionAccessNumberParser(p))); result.Add(new AutoAccessNumberParser(parsers)); } else { result.Add(DefaultAccessNumberParser.GetInstance()); } return(result); }
public static IAccessNumberParser GuessParser(string databaseFileName) { FastaFormat ff = new FastaFormat(); using (StreamReader sr = new StreamReader(databaseFileName)) { Sequence seq; while ((seq = ff.ReadSequence(sr)) != null) { if (seq.Reference.StartsWith("IPI")) { return(new NoExceptionAccessNumberParser(new IPIAccessNumberParser())); } if (seq.Reference.StartsWith("gi|")) { return(new NoExceptionAccessNumberParser(new NRAccessNumberParser())); } } } return(DefaultAccessNumberParser.GetInstance()); }
public void TestGetValue() { Assert.AreEqual("ABCDE", DefaultAccessNumberParser.GetInstance().GetValue("ABCDE")); Assert.AreEqual("ABCDE", DefaultAccessNumberParser.GetInstance().GetValue("ABCDE GEHDKG")); }