Ejemplo n.º 1
0
        /// <summary>
        /// Search sequence online in the corresponding DB
        /// </summary>
        public void RetrieveSequences()
        {
            WSDBFetchServerService db = new WSDBFetchServerService();

            foreach (PSIPIanalysissearchDBSequenceType p in ListProteins)
            {
                if (p.seq != null)
                {
                    continue;
                }
                if (p.SearchDatabase_ref.ToUpper() != "SDB_SWISSPROT")
                {
                    throw new ApplicationException("DB " + p.SearchDatabase_ref + " not supported");
                }
                Console.WriteLine("Retrieving " + p.accession + " ...");
                string fasta = db.fetchData("UNIPROT:" + p.accession, "fasta", "raw");
                fasta = fasta.Remove(0, fasta.IndexOf('\n'));
                string seq = "";
                foreach (string str in fasta.Split('\n'))
                {
                    seq += str;
                }
                p.seq = seq;        //seq.ToUpper();
            }
        }
        public string GetFASTA(string accessionNumber)
        {
            WSDBFetchServerService fetch = new WSDBFetchServerService();

            try
            {
                string result = fetch.fetchData("UniProtKB: Accession: " + accessionNumber, "FASTA", "RAW");
                return(result);
            }
            catch (Exception e)
            {
                string problem = "There was a Problem with your request. Please check that  your accession number is correct and that the record is on the UNIprotKB database.";
                return(problem);
            }
        }
        public string[] GetDatabases()
        {
            string[] result = null;
            WSDBFetchServerService fetch = new WSDBFetchServerService();

            try
            {
                result = fetch.getSupportedDBs();
                return(result);
            }
            catch (Exception e)
            {
                result[0] = "NO DATABASES FOUND";
            }
            return(result);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Search sequence online in the corresponding DB
 /// </summary>
 public void RetrieveSequences()
 {
     WSDBFetchServerService db = new WSDBFetchServerService();
     foreach( DBSequenceType p in ListProteins ) {
     if( p.Seq!= null )
         continue;
     if( p.searchDatabase_ref.ToUpper() != "SDB_SWISSPROT" )
         throw new ApplicationException( "DB " + p.searchDatabase_ref + " not supported" );
     Console.WriteLine( "Retrieving " + p.accession + " ..." );
     string fasta = db.fetchData("UNIPROT:"+p.accession, "fasta", "raw");
     fasta = fasta.Remove(0,fasta.IndexOf('\n'));
     string seq = "";
     foreach( string str in fasta.Split('\n') )
         seq += str;
     p.Seq = seq;//seq.ToUpper();
     }
 }
Ejemplo n.º 5
0
        public static void runCosmic( string file )
        {
            StreamReader rd = new StreamReader(new GZipStream(new FileStream(file,FileMode.Open), CompressionMode.Decompress));
            string line;
            char[] sep1 = new char[]{','};
            char[] sep2 = new char[]{':'};
            string[] fields, fields2;
            String mut, prot;
            Variant v;
            Fasta f;
            List<string> ids = new List<string>();
            SortedList<string,Fasta> fasta = new SortedList<string, Fasta>();
            bool first = true;
            //int count = 1;
            while( (line=rd.ReadLine()) != null ) {
            if( first ) {
                first = false;
                continue;
            }
            fields = line.Split(sep1);
            if( fields[4].Length == 0 )
                continue;
            if( fasta.ContainsKey(fields[4]) )
                f = fasta[fields[4]];
            else {
                WSDBFetchServerService server = new WSDBFetchServerService();
                server.
                f = new Fasta(Fasta.Type.Protein,fields[4],seq);
            }

            v = new Variant();
            if( ids.Contains(fields[4]) )
                continue;
            ids.Add(fields[0]);
            sreq.id = fields[0];
            sres = ssrv.run_eFetch( sreq );
            if( sres == null || sres.ExchangeSet.Rs == null || sres.ExchangeSet.Rs.Length == 0 )
                continue;
            Console.WriteLine( fields[0] + "..." );
            foreach( string str in sres.ExchangeSet.Rs[0].hgvs ) {
                if( !str.StartsWith("NP_") )
                    continue;
                Console.Write( str + " " );
                v = new Variant();
                v.id = str;
                fields2 = str.Split(sep2);
                mut = fields2[1]; prot = fields2[0];
                try {
                    v.orig = AminoAcid.Get(mut.Substring(2,3)).Letter;
                    v.mut = AminoAcid.Get(mut.Substring(mut.Length-3,3)).Letter;
                    v.pos = ulong.Parse(mut.Substring(5,mut.Length-8))-1;
                } catch {
                    Console.WriteLine( "(filtered)" );
                    continue;
                }
                if( fasta.ContainsKey(prot) ) {
                    Console.WriteLine( "(cached)" );
                    f = fasta[prot];
                } else {
                    preq.db = "protein";
                    preq.id = prot;
                    pres = psrv.run_eFetch( preq );
                    f = new Fasta(Fasta.Type.Protein,prot+"|"+pres.GBSet[0].GBSeq_definition,pres.GBSet[0].GBSeq_sequence);
                    fasta.Add( prot, f );
                    Console.WriteLine( "(downloaded)" );
                }
                f.mVariants.Add( v );
            }
            /*if( --count == 0 )
                break;*/
            }

            foreach( Fasta fas in fasta.Values )
            fas.Dump( true );
        }
Ejemplo n.º 6
0
        public static void runCosmic(string file)
        {
            StreamReader rd = new StreamReader(new GZipStream(new FileStream(file, FileMode.Open), CompressionMode.Decompress));
            string       line;

            char[]        sep1 = new char[] { ',' };
            char[]        sep2 = new char[] { ':' };
            string[]      fields, fields2;
            String        mut, prot;
            Variant       v;
            Fasta         f;
            List <string> ids = new List <string>();
            SortedList <string, Fasta> fasta = new SortedList <string, Fasta>();
            bool first = true;

            //int count = 1;
            while ((line = rd.ReadLine()) != null)
            {
                if (first)
                {
                    first = false;
                    continue;
                }
                fields = line.Split(sep1);
                if (fields[4].Length == 0)
                {
                    continue;
                }
                if (fasta.ContainsKey(fields[4]))
                {
                    f = fasta[fields[4]];
                }
                else
                {
                    WSDBFetchServerService server = new WSDBFetchServerService();
                    server.
                    f = new Fasta(Fasta.Type.Protein, fields[4], seq);
                }

                v = new Variant();
                if (ids.Contains(fields[4]))
                {
                    continue;
                }
                ids.Add(fields[0]);
                sreq.id = fields[0];
                sres    = ssrv.run_eFetch(sreq);
                if (sres == null || sres.ExchangeSet.Rs == null || sres.ExchangeSet.Rs.Length == 0)
                {
                    continue;
                }
                Console.WriteLine(fields[0] + "...");
                foreach (string str in sres.ExchangeSet.Rs[0].hgvs)
                {
                    if (!str.StartsWith("NP_"))
                    {
                        continue;
                    }
                    Console.Write(str + " ");
                    v       = new Variant();
                    v.id    = str;
                    fields2 = str.Split(sep2);
                    mut     = fields2[1]; prot = fields2[0];
                    try {
                        v.orig = AminoAcid.Get(mut.Substring(2, 3)).Letter;
                        v.mut  = AminoAcid.Get(mut.Substring(mut.Length - 3, 3)).Letter;
                        v.pos  = ulong.Parse(mut.Substring(5, mut.Length - 8)) - 1;
                    } catch {
                        Console.WriteLine("(filtered)");
                        continue;
                    }
                    if (fasta.ContainsKey(prot))
                    {
                        Console.WriteLine("(cached)");
                        f = fasta[prot];
                    }
                    else
                    {
                        preq.db = "protein";
                        preq.id = prot;
                        pres    = psrv.run_eFetch(preq);
                        f       = new Fasta(Fasta.Type.Protein, prot + "|" + pres.GBSet[0].GBSeq_definition, pres.GBSet[0].GBSeq_sequence);
                        fasta.Add(prot, f);
                        Console.WriteLine("(downloaded)");
                    }
                    f.mVariants.Add(v);
                }

                /*if( --count == 0 )
                 *      break;*/
            }

            foreach (Fasta fas in fasta.Values)
            {
                fas.Dump(true);
            }
        }