<commit_before>﻿///////////////////////////////////////////////////////////////////////////
//  Examples.cs - A collection of examples of how to use CSMSL            /
//                                                                        /
//  Copyright 2012 <NAME>                                        /
//  This file is part of CSMSL.                                           /
//                                                                        /
//  CSMSL is free software: you can redistribute it and/or modify         /
//  it under the terms of the GNU General Public License as published by  /
//  the Free Software Foundation, either version 3 of the License, or     /
//  (at your option) any later version.                                   /
//                                                                        /
//  CSMSL is distributed in the hope that it will be useful,              /
//  but WITHOUT ANY WARRANTY; without even the implied warranty of        /
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         /
//  GNU General Public License for more details.                          /
//                                                                        /
//  You should have received a copy of the GNU General Public License     /
//  along with CSMSL.  If not, see <http://www.gnu.org/licenses/>.        /
///////////////////////////////////////////////////////////////////////////

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using CSMSL.Chemistry;
using CSMSL.Proteomics;
using CSMSL.Util;
using CSMSL.IO.Thermo;
using CSMSL.IO;
using CSMSL.Spectral;

namespace ExamplesCSMSL
{
    internal class Examples
    {
        private static void Main(string[] args)
        {
            Console.WriteLine("==CSMSL Examples==");
            Stopwatch watch = new Stopwatch();
            watch.Start();
            StartExamples();
            watch.Stop();
            Console.WriteLine("==================");
            Console.WriteLine(watch.Elapsed);
            Console.ReadKey();
        }

        private static void StartExamples()
        {
            // Examples coding
            //ChemicalFormulaExamples();
           // PeptideExamples();

            // Example Objects
            //VennDiagramExamples();

            // Example programs
            //ExampleTrypticDigest.Start();

            //Example IO
            MsIOExamples();
        }

        private static void MsIOExamples()
        {
            Console.WriteLine("**MS I/O Examples**");

            // Ms Data Files implment IDispoable making using statements an excellent way to manage resources
            using (MsDataFile dataFile = new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw", true))
            {     
                int counter = 0;  
                foreach (MsScan scan in dataFile.OfType<MsnScan>())
                {                      
                    Console.WriteLine("Scan #{0} MSn Order: {1} Time: {2:f3} Polarity: {3} Spectrum: {4} M/Z Analyzer: {5} type: {6}", scan.SpectrumNumber, scan.MsnOrder, scan.RetentionTime, scan.Polarity, scan.Spectrum, scan.MzAnalyzer, scan.GetType());
                }
                Console.WriteLine(counter);                    
            }
        }

        private static void VennDiagramExamples()
        {
            Console.WriteLine("**Venn Diagram Examples**");

            // Generate some random data of integers
            Console.WriteLine("Generating Random Values");
            int numberofsets = 5;
            int maxvalue = 100;
            int maxitems = 50;
            Random ran = new Random();
            VennSet<int>[] sets = new VennSet<int>[numberofsets];
            for (int i = 0; i < numberofsets; i++)
            {
                sets[i] = new VennSet<int>(string.Format("Set {0}", i));
                for (int j = 0; j < maxitems; j++)
                {
                    sets[i].Add(ran.Next(maxvalue));<commit_msg>Basic example refractoring<commit_after>﻿///////////////////////////////////////////////////////////////////////////
//  Examples.cs - A collection of examples of how to use CSMSL            /
//                                                                        /
//  Copyright 2012 <NAME>                                        /
//  This file is part of CSMSL.                                           /
//                                                                        /
//  CSMSL is free software: you can redistribute it and/or modify         /
//  it under the terms of the GNU General Public License as published by  /
//  the Free Software Foundation, either version 3 of the License, or     /
//  (at your option) any later version.                                   /
//                                                                        /
//  CSMSL is distributed in the hope that it will be useful,              /
//  but WITHOUT ANY WARRANTY; without even the implied warranty of        /
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         /
//  GNU General Public License for more details.                          /
//                                                                        /
//  You should have received a copy of the GNU General Public License     /
//  along with CSMSL.  If not, see <http://www.gnu.org/licenses/>.        /
///////////////////////////////////////////////////////////////////////////

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using CSMSL.Chemistry;
using CSMSL.Proteomics;
using CSMSL.Util;
using CSMSL.IO.Thermo;
using CSMSL.IO;
using CSMSL.Spectral;

namespace ExamplesCSMSL
{
    internal class Examples
    {
        private static void Main(string[] args)
        {
            Console.WriteLine("==CSMSL Examples==");
            Stopwatch watch = new Stopwatch();
            watch.Start();
            StartExamples();
            watch.Stop();
            Console.WriteLine("==================");
            Console.WriteLine(watch.Elapsed);
            Console.ReadKey();
        }

        private static void StartExamples()
        {
            // Examples coding
            //ChemicalFormulaExamples();
           // PeptideExamples();

            // Example Objects
            //VennDiagramExamples();

            // Example programs
            //ExampleTrypticDigest.Start();

            //Example IO
            MsIOExamples();
        }

        private static void MsIOExamples()
        {
            Console.WriteLine("**MS I/O Examples**");

            // Ms Data Files implement IDispoable making using statements an excellent way to manage resources
            using (MsDataFile dataFile = new ThermoRawFile("Resources/ThermoRawFileMS1MS2.raw", true))
            {
                Console.WriteLine("{0,-4} {1} {2,-5} {3,-5} {4,-10} {5,-3} {6} {7}", "Scan #", "Msn Order", "Retention Time", "Polarity", "Spectrum", "MzAnalyzer", "DataType", "MzRange");
                foreach (MsScan scan in dataFile)
                {                      
                    Console.WriteLine("{0,-4} {1} {2,-5:F4} {3,-5} {4,-10} {5,-3} {6} {7}", 
                        scan.SpectrumNumber, 
                        scan.MsnOrder, 
                        scan.RetentionTime, 
                        scan.Polarity, 
                        scan.Spectrum, 
                        scan.MzAnalyzer, 
                        scan.GetType(),
                        scan.MzRange);
                }                                 
            }
        }

        private static void VennDiagramExamples()
        {
            Console.WriteLine("**Venn Diagram Examples**");

            // Generate some random data of integers
            Console.WriteLine("Generating Random Values");
            int numberofsets = 5;
            int maxvalue = 100;
            int maxitems = 50;
            Random ran = new Random();
            VennSet<int>[] sets = new VennSet<int>[numberofsets];
            for (int i = 0; i < numberofsets; i++)
            {
                sets[i] = new VennSet<int>(string.Format("Set {0}", i));
                for (int j = 0; j < maxitems; j++)
                {
                    sets[i].Add(ran.Next(maxvalue));
{'fraction_non_alphanumeric': 0.13291821338761825, 'fraction_numerical': 0.008382229673093043, 'mean_word_length': 1.1492537313432836, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1834064', 'n_tokens_mistral': 2014, 'n_tokens_neox': 1881, 'n_words': 582}