Ejemplo n.º 1
0
        private List <cSequence> ExtractFileData(List <cLine> pLsLines)
        {
            List <cSequence>     lsSequences     = new List <cSequence>();
            List <cSequenceRead> lsSequenceReads = new List <cSequenceRead>();

            foreach (cLine line in pLsLines)
            {
                if (lsSequences.FindAll(item => item.RNAME == line.RNAME).Count == 0)
                {
                    cSequence newSequence = new cSequence();
                    newSequence.RNAME = line.RNAME;
                    lsSequences.Add(newSequence);
                }

                cSequenceRead newRead = new cSequenceRead();
                newRead.QNAME = line.QNAME.Trim();
                newRead.FLAG  = int.Parse(line.FLAG);
                newRead.POS   = int.Parse(line.POS);
                newRead.MAPQ  = int.Parse(line.MAPQ);
                newRead.CIGAR = line.CIGAR.Trim();
                newRead.MPOS  = int.Parse(line.MPOS);
                newRead.ISIZE = int.Parse(line.ISIZE);
                newRead.SEQ   = line.SEQ.Trim();
                newRead.QUAL  = line.QUAL.Trim();

                newRead.OPTIONS = new List <cOption>();
                foreach (string opt in line.OPTIONS)
                {
                    newRead.OPTIONS.Add(new cOption(opt));
                }

                if (line.MRNM == "=")
                {
                    //newRead.MRNM = lsSequences.First(item => item.RNAME == line.RNAME).idSequence;
                }
                else
                {
                    newRead.MRNM = lsSequences.First(item => item.RNAME == line.MRNM).idSequence;
                }
                if (lsSequences.First(item => item.RNAME == line.RNAME).Reads == null)
                {
                    lsSequences.First(item => item.RNAME == line.RNAME).Reads = new List <cSequenceRead>();
                }

                newRead.GestionINDEL();
                //newRead.GestionAmorces();

                lsSequences.First(item => item.RNAME == line.RNAME).Reads.Add(newRead);
            }

            // lsSequences.ForEach(i => i.Reads.GroupBy(j => j.QNAME));

            return(lsSequences);
        }
Ejemplo n.º 2
0
        private void LoadReads()
        {
            MySqlCommand         cmd     = this.CreateCommand();
            List <cSequenceRead> lsReads = new List <cSequenceRead>();

            cmd.CommandText = "SELECT ID_SEQUENCE_READ, ID_SEQUENCE, QNAME, FLAG, POS, MAPQ, CIGAR, MRNM, MPOS, ISIZE, SEQ, QUAL FROM SEQUENCE_READ WHERE ID_SEQUENCE = @ID_SEQUENCE;";
            cmd.Parameters.AddWithValue("@ID_SEQUENCE", this.idSequence);

            try
            {
                this.OpenConnection();

                MySqlDataReader dr = cmd.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        cSequenceRead read = new cSequenceRead
                        {
                            idSequenceRead = dr.GetInt64("ID_SEQUENCE_READ"),
                            QNAME          = dr.GetString("QNAME"),
                            FLAG           = dr.GetInt32("FLAG"),
                            POS            = dr.GetInt32("POS"),
                            MAPQ           = dr.GetInt32("MAPQ"),
                            CIGAR          = dr.GetString("CIGAR"),
                            MRNM           = dr.GetInt32("MRNM"),
                            MPOS           = dr.GetInt32("MPOS"),
                            ISIZE          = dr.GetInt32("ISIZE"),
                            SEQ            = dr.GetString("SEQ"),
                            QUAL           = dr.GetString("QUAL")
                        };

                        read.GestionINDEL();

                        lsReads.Add(read);
                    }
                }

                this.CloseConnection();
            }
            catch (Exception ex)
            {
                this.CloseConnection();
                throw;
            }


            this.Reads = lsReads;
        }
Ejemplo n.º 3
0
        private string truncateSequence(cSequenceRead read, bool isDebut)
        {
            int lng = 0;

            if (read.SEQCorrige.Length > 0)
            {
                lng = this.getLongAmorce(read.SEQCorrige.Length);
            }

            if (lng == 0)
            {
                return(read.SEQCorrige);
            }

            string sequence;

            try
            {
                if (lng > read.SEQCorrige.Length)
                {
                    return(string.Empty);
                }
                if (!isDebut)
                {
                    sequence = reverseString(reverseString(read.SEQCorrige).Remove(0, lng));
                }
                else
                {
                    sequence = read.SEQCorrige.Remove(0, lng);
                }
                return(sequence);
            } catch (Exception ex)
            {
                return(read.SEQCorrige);
            }
        }
Ejemplo n.º 4
0
 public string truncateSequence(cSequenceRead sequence)
 {
     return(truncateSequence(sequence, this.FLAG == 99 || this.FLAG == 163));
 }