Ejemplo n.º 1
0
        /// <summary>
        /// VAlidates mandatory tags.
        /// </summary>
        /// <returns>Returns empty string if mandatory tags are present; otherwise error message.</returns>
        public string IsValid()
        {
            if (RecordFields.Count == 0)
            {
                return(string.Empty);
            }

            if (RecordFields.Count(RF => RF == null) > 0)
            {
                return(string.Format(CultureInfo.CurrentCulture, Properties.Resource.HeaderContainsNullValue));
            }

            List <SAMRecordField> fieldsToValidate = RecordFields.Where(F => MandatoryTagsForFieldTypes.Keys.Contains(F.Typecode,
                                                                                                                      StringComparer.InvariantCultureIgnoreCase)).ToList();

            foreach (SAMRecordField field in fieldsToValidate)
            {
                foreach (string tag in MandatoryTagsForFieldTypes[field.Typecode])
                {
                    if (field.Tags.FirstOrDefault(T => string.Compare(T.Tag, tag, StringComparison.InvariantCultureIgnoreCase) == 0) == null)
                    {
                        return(string.Format(CultureInfo.CurrentCulture, Properties.Resource.MandatoryTagNotFound, tag, field.Typecode));
                    }
                }
            }

            return(string.Empty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns list of reference sequences present in this header.
        /// </summary>
        public IList <string> GetReferenceSequences()
        {
            List <string>         refSequences = new List <string>();
            List <SAMRecordField> fields       = RecordFields.Where(R => String.Compare(R.Typecode, "SQ", StringComparison.OrdinalIgnoreCase) == 0).ToList();

            foreach (SAMRecordField field in fields)
            {
                SAMRecordFieldTag tag = field.Tags.FirstOrDefault(F => String.Compare(F.Tag, "SN", StringComparison.OrdinalIgnoreCase) == 0);
                if (tag != null)
                {
                    refSequences.Add(tag.Value);
                }
            }

            return(refSequences);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns list of reference sequences name and length present in SQ header.
        /// </summary>
        public IList <ReferenceSequenceInfo> GetReferenceSequencesInfoFromSQHeader()
        {
            List <ReferenceSequenceInfo> refSequencesInfo = new List <ReferenceSequenceInfo>();
            List <SAMRecordField>        fields           = RecordFields.Where(R => String.Compare(R.Typecode, "SQ", StringComparison.OrdinalIgnoreCase) == 0).ToList();

            foreach (SAMRecordField field in fields)
            {
                SAMRecordFieldTag tag = field.Tags.FirstOrDefault(F => String.Compare(F.Tag, "SN", StringComparison.OrdinalIgnoreCase) == 0);
                if (tag != null)
                {
                    string refName = tag.Value;
                    long   length;
                    tag = field.Tags.FirstOrDefault(F => String.Compare(F.Tag, "LN", StringComparison.OrdinalIgnoreCase) == 0);
                    if (tag != null && long.TryParse(tag.Value, out length))
                    {
                        refSequencesInfo.Add(new ReferenceSequenceInfo(refName, length));
                    }
                }
            }

            return(refSequencesInfo);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns list of SequenceRanges objects which represents reference sequences present in this header.
        /// </summary>
        public IList <SequenceRange> GetReferenceSequenceRanges()
        {
            List <SequenceRange>  ranges = new List <SequenceRange>();
            List <SAMRecordField> fields = RecordFields.Where(R => String.Compare(R.Typecode, "SQ", StringComparison.OrdinalIgnoreCase) == 0).ToList();

            foreach (SAMRecordField field in fields)
            {
                SAMRecordFieldTag tag = field.Tags.FirstOrDefault(F => String.Compare(F.Tag, "SN", StringComparison.OrdinalIgnoreCase) == 0);
                if (tag != null)
                {
                    string refName = tag.Value;
                    long   length;
                    tag = field.Tags.FirstOrDefault(F => String.Compare(F.Tag, "LN", StringComparison.OrdinalIgnoreCase) == 0);
                    if (tag != null && long.TryParse(tag.Value, out length))
                    {
                        SequenceRange range = new SequenceRange(refName, 0, length);
                        ranges.Add(range);
                    }
                }
            }

            return(ranges.OrderBy(S => S.ID).ToList());
        }
 public override void Init()
 {
     recordFields = new RecordFields();
     timer1 = new System.Timers.Timer();
     timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Tick);
     timer1.Interval = timer_interval;
     timer1.Enabled = true;
     try
     {
         if (usingRegistry)
         {
             if (!reg_flag)
             {
                 if (!Read_Registry())
                 {
                     L.Log(LogType.FILE, LogLevel.ERROR, "Error on Reading the Registry ");
                     return;
                 }
                 else
                     if (!Initialize_Logger())
                     {
                         L.Log(LogType.FILE, LogLevel.ERROR, "Error on Intialize Logger on Meyer Recorder functions may not be running");
                         return;
                     }
                 reg_flag = true;
                 //Database.CreateDatabase();
             }
         }
         else
         {
             if (!reg_flag)
             {
                 if (!Get_logDir())
                 {
                     L.Log(LogType.FILE, LogLevel.ERROR, "Error on Reading the Registry ");
                     return;
                 }
                 else
                     if (!Initialize_Logger())
                     {
                         L.Log(LogType.FILE, LogLevel.ERROR, "Error on Intialize Logger on Meyer Recorder functions may not be running");
                         return;
                     }
                 L.Log(LogType.FILE, LogLevel.INFORM, "Start creating Meyer DAL");
                 reg_flag = true;
                 //Database.CreateDatabase();
                 db_name = "master";
                 if (Database.AddConnection(db_name, Database.Provider.SQLServer, remote_host, user, password, location))
                 {
                     L.Log(LogType.FILE, LogLevel.INFORM, "Successfully create Meyer DAL");
                 }
                 else
                 {
                     L.Log(LogType.FILE, LogLevel.INFORM, "Failed on creating Meyer DAL");
                 }
             }
         }
     }
     catch (Exception er)
     {
         EventLog.WriteEntry("Security Manager Meyer Recorder Init", er.ToString(), EventLogEntryType.Error);
     }
     L.Log(LogType.FILE, LogLevel.DEBUG, "Exit Init Function.");
 }