Ejemplo n.º 1
0
 public void TestPublicationSetUp()
 {
     pubTypes = new PublicationTypes(
         AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
         "PublicationTypes.csv"
         );
 }
Ejemplo n.º 2
0
        public async Task <int> Create(string imageUrl, string description, string userId, string sharedBy)
        {
            PublicationTypes type = string.IsNullOrEmpty(imageUrl) ? PublicationTypes.Post : PublicationTypes.Image;

            if (string.IsNullOrEmpty(imageUrl) && string.IsNullOrEmpty(description))
            {
                return(-1);
            }

            Publication publication = new Publication()
            {
                Type        = type,
                Description = description,
                ImageUrl    = imageUrl,
                CreatorId   = userId,
                CreatedOn   = DateTime.UtcNow
            };

            if (!String.IsNullOrEmpty(sharedBy))
            {
                publication.SharedById = sharedBy;
            }

            this.data.Add(publication);

            await this.data.SaveChangesAsync();

            return(publication.Id);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="roster">AAMC roster object</param>
 /// <param name="alternateTableName">Alternate PeoplePublications table name, null if not using it</param>
 public ColleagueFinder(Database DB, Roster roster, NCBI ncbi, string alternateTableName)
 {
     this.DB            = DB;
     this.roster        = roster;
     this.ncbi          = ncbi;
     this.harvester     = new Harvester(DB);
     this.pubTypes      = new PublicationTypes(DB);
     AlternateTableName = alternateTableName;
 }
Ejemplo n.º 4
0
        public void EmptyMedlineString()
        {
            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );
            Publications mpr = new Publications("", ptc);

            Assert.IsNull(mpr.PublicationList);
        }
        public void ResetDatabase()
        {
            // Import "TestPeopleMaintenance/input1 plus testhyphens.xls" into the People table
            People PeopleFromFile = new People(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPeopleMaintenance",
                "input1 plus testhypens.xls");

            DB = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            MockNCBI mockNCBI = new MockNCBI("medline");

            mockNCBI.SearchThrowsAnError = false;
            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            ptc.WriteToDB(DB);


            // Anonymous callback functions for GetPublications
            Harvester.GetPublicationsStatus StatusCallback = delegate(int number, int total, int averageTime)
            {
                //
            };
            Harvester.GetPublicationsMessage MessageCallback = delegate(string Message, bool StatusBarOnly)
            {
                //
            };
            Harvester.CheckForInterrupt InterruptCallback = delegate()
            {
                return(false);
            };

            // Write the people, then "harvest" the publications using MockNCBI
            double AverageMilliseconds;

            foreach (Person person in PeopleFromFile.PersonList)
            {
                person.WriteToDB(DB);
                harvester.GetPublications(mockNCBI, ptc, person, StatusCallback, MessageCallback, InterruptCallback, out AverageMilliseconds);
            }

            People PeopleFromDB = new People(DB);

            Assert.AreEqual(PeopleFromDB.PersonList.Count, 4);
        }
 public void InvalidFilename()
 {
     try
     {
         PublicationTypes ptc = new PublicationTypes(
             AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
             "this is an invalid filename"
             );
         Assert.Fail();
     }
     catch
     {
         Assert.IsTrue(true);
     }
 }
 public void InvalidCategory()
 {
     try {
         // Read the publication types from the CSV file
         PublicationTypes ptc = new PublicationTypes(
             AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
             "Invalid Category.csv"
             );
         Assert.Fail();
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex.Message.Contains("Newspaper Article"));
     }
 }
 public void InvalidFolder()
 {
     try
     {
         PublicationTypes ptc = new PublicationTypes(
             "xyz1234",
             "PublicationTypes.csv"
             );
         Assert.Fail();
     }
     catch
     {
         Assert.IsTrue(true);
     }
 }
 public void DuplicateType()
 {
     try
     {
         // Read the publication types from the CSV file
         PublicationTypes ptc = new PublicationTypes(
             AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
             "Duplicate Type.csv"
             );
         Assert.Fail();
     }
     catch (Exception ex)
     {
         Assert.IsTrue(ex.Message.Contains("Historical Article"));
     }
 }
Ejemplo n.º 10
0
        public void EmptyPublicationList()
        {
            string emptySearchResults = @"<?xml version=""1.0"" encoding=""UTF-8""?>

<eFetchResult>
        <ERROR>Empty result - nothing to do</ERROR>
</eFetchResult>";

            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            Publications mpr = new Publications(emptySearchResults, ptc);

            Assert.IsNull(mpr.PublicationList);
        }
        public void ReadAndWritePublicationTypes()
        {
            // Read the publication types from the CSV file
            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            Assert.AreEqual(ptc.Categories.Count, 52);
            Assert.AreEqual(ptc.GetCategoryNumber("Legislation"), 0);
            Assert.AreEqual(ptc.GetCategoryNumber("Consensus Development Conference, NIH"), 1);
            Assert.AreEqual(ptc.GetCategoryNumber("Review, Multicase"), 2);
            Assert.AreEqual(ptc.GetCategoryNumber("Technical Report"), 3);
            Assert.AreEqual(ptc.GetCategoryNumber("Comment"), 4);

            // Verify OverrideFirstCategory values
            Assert.IsTrue(ptc.OverrideFirstCategory.ContainsKey("Review"));
            Assert.IsTrue(ptc.OverrideFirstCategory.ContainsKey("Review, Multicase"));
            Assert.AreEqual(ptc.OverrideFirstCategory.ContainsKey("Comment"), false);


            // First recreate the database, then write the publication types to it
            Database  DB        = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            ptc.WriteToDB(DB);

            // Read the publication types from the database
            PublicationTypes ptcFromDB =
                new PublicationTypes(DB);

            Assert.AreEqual(ptcFromDB.Categories.Count, 52);
            Assert.AreEqual(ptcFromDB.GetCategoryNumber("Overall"), 0);
            Assert.AreEqual(ptcFromDB.GetCategoryNumber("Clinical Trial, Phase II"), 1);
            Assert.AreEqual(ptcFromDB.GetCategoryNumber("Review of Reported Cases"), 2);
            Assert.AreEqual(ptcFromDB.GetCategoryNumber("Technical Report"), 3);
            Assert.AreEqual(ptcFromDB.GetCategoryNumber("Letter"), 4);
            Assert.AreEqual(ptcFromDB.GetCategoryNumber("Comment"), 4);

            // Verify OverrideFirstCategory values
            Assert.IsTrue(ptcFromDB.OverrideFirstCategory.ContainsKey("Review"));
            Assert.IsTrue(ptcFromDB.OverrideFirstCategory.ContainsKey("Review, Multicase"));
            Assert.AreEqual(ptcFromDB.OverrideFirstCategory.ContainsKey("Comment"), false);
        }
Ejemplo n.º 12
0
        public void TestCreateFromDatabase()
        {
            // Add a publication to the database
            Database  DB        = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            Publication      write = CreateTestPublication();
            PublicationTypes ptc   = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            Publications.WriteToDB(write, DB, ptc, new string[] { "eng" });

            // Read it back
            Publication read;

            Assert.IsTrue(Publications.GetPublication(DB, 15904469, out read, false));
            TestCreatedPublication(read);
        }
Ejemplo n.º 13
0
        public void LeadingBlankLines()
        {
            #region Test HandGeneratedData
            string MedlineData = @"











PMID- 15856074
OWN - NLM
STAT- In-Data-Review
DA  - 20051118
PUBM- Print
IS  - 1053-4245
VI  - 15
IP  - 6
DP  - 2005 Nov
TI  - Residential environmental exposures and other characteristics associated
      with detectable PAH-DNA adducts in peripheral mononuclear cells in a
      population-based sample of adult females.
PG  - 482-90
AB  - The detection of polycyclic aromatic hydrocarbon (PAH)-DNA adducts in
      human lymphocytes may be useful as a surrogate end point for individual
      cancer risk prediction. In this study, we examined the relationship
      between environmental sources of residential PAH, as well as other
      potential factors that may confound their association with cancer risk,
      and the detection of PAH-DNA adducts in a large population-based sample of
      adult women. Adult female residents of Long Island, New York, aged at
      least 20 years were identified from the general population between August
      1996 and July 1997. Among 1556 women who completed a structured
      questionnaire, 941 donated sufficient blood (25+ ml) to allow use of a
      competitive ELISA for measurement of PAH-DNA adducts in peripheral blood
      mononuclear cells. Ambient PAH exposure at the current residence was
      estimated using geographic modeling (n=796). Environmental home samples of
      dust (n=356) and soil (n=360) were collected on a random subset of
      long-term residents (15+ years). Multivariable regression was conducted to
      obtain the best-fitting predictive models. Three separate models were
      constructed based on data from : (A) the questionnaire, including a
      dietary history; (B) environmental home samples; and (C) geographic
      modeling. Women who donated blood in summer and fall had increased odds of
      detectable PAH-DNA adducts (OR=2.65, 95% confidence interval (CI)=1.69,
      4.17; OR=1.59, 95% CI=1.08, 2.32, respectively), as did current and past
      smokers (OR=1.50, 95% CI=1.00, 2.24; OR=1.46, 95% CI=1.05, 2.02,
      respectively). There were inconsistent associations between detectable
      PAH-DNA adducts and other known sources of residential PAH, such as
      grilled and smoked foods, or a summary measure of total dietary
      benzo-[a]-pyrene (BaP) intake during the year prior to the interview.
      Detectable PAH-DNA adducts were inversely associated with increased BaP
      levels in dust in the home, but positively associated with BaP levels in
      soil outside of the home, although CIs were wide. Ambient BaP estimates
      from the geographic model were not associated with detectable PAH-DNA
      adducts. These data suggest that PAH-DNA adducts detected in a
      population-based sample of adult women with ambient exposure levels
      reflect some key residential PAH exposure sources assessed in this study,
      such as cigarette smoking.Journal of Exposure Analysis and Environmental
      Epidemiology (2005) 15, 482-490. doi:10.1038/sj.jea.7500426; published
      online 27 April 2005.
AD  - aDepartment of Epidemiology, CB#7435 McGavran-Greenberg Hall, University
      of North Carolina School of Public Health, Chapel Hill, North Carolina
      27599-7435, USA.
FAU - Shantakumar, Sumitra
AU  - Shantakumar S
FAU - Gammon, Marilie D
AU  - Gammon MD
FAU - Eng, Sybil M
AU  - Eng SM
FAU - Sagiv, Sharon K
AU  - Sagiv SK
FAU - Gaudet, Mia M
AU  - Gaudet MM
FAU - Teitelbaum, Susan L
AU  - Teitelbaum SL
FAU - Britton, Julie A
AU  - Britton JA
FAU - Terry, Mary Beth
AU  - Terry MB
FAU - Paykin, Andrea
AU  - Paykin A
FAU - Young, Tie Lan
AU  - Young TL
FAU - Wang, Lian Wen
AU  - Wang LW
FAU - Wang, Qiao
AU  - Wang Q
FAU - Stellman, Steven D
AU  - Stellman SD
FAU - Beyea, Jan
AU  - Beyea J
FAU - Hatch, Maureen
AU  - Hatch M
FAU - Camann, David
AU  - Camann D
FAU - Prokopczyk, Bogdan
AU  - Prokopczyk B
FAU - Kabat, Geoffrey C
AU  - Kabat GC
FAU - Levin, Bruce
AU  - Levin B
FAU - Neugut, Alfred I
AU  - Neugut AI
FAU - Santella, Regina M
AU  - Santella RM
LA  - eng
PT  - Journal Article
PL  - England
TA  - J Expo Anal Environ Epidemiol
JID - 9111438
SB  - IM
EDAT- 2005/04/28 09:00
MHDA- 2005/04/28 09:00
AID - 7500426 [pii]
AID - 10.1038/sj.jea.7500426 [doi]
PST - ppublish
SO  - J Expo Anal Environ Epidemiol 2005 Nov;15(6):482-90.";
            #endregion

            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );
            Publications mpr = new Publications(MedlineData, ptc);
            Assert.IsTrue(mpr.PublicationList.Length == 1);
            Publication p = mpr.PublicationList[0];
            Assert.AreEqual(p.PMID, 15856074);
            Assert.AreEqual(p.Year, 2005);
            Assert.IsTrue(p.Month == "Nov");
            Assert.IsNull(p.Day);
            Assert.IsTrue(p.Title == "Residential environmental exposures and other characteristics associated with detectable PAH-DNA adducts in peripheral mononuclear cells in a population-based sample of adult females.");
            Assert.IsTrue(p.Pages == "482-90");
            Assert.IsTrue(p.Journal == "J Expo Anal Environ Epidemiol");
            Assert.IsTrue(p.Volume == "15");
            Assert.IsTrue(p.Issue == "6");
            Assert.IsNull(p.Grants);
            Assert.IsTrue(p.PubType == "Journal Article");
            Assert.IsNull(p.MeSHHeadings);
            Assert.IsTrue(p.Authors.Length == 21);
            Assert.IsTrue(p.Authors[0] == "Shantakumar S");
            Assert.IsTrue(p.Authors[20] == "Santella RM");
        }
Ejemplo n.º 14
0
        public void TestWriteToDB()
        {
            // Create a new database and write the publication to it
            Database  DB = new Database("Publication Harvester Unit Test");
            Harvester h  = new Harvester(DB);

            h.CreateTables();
            Publication      p   = CreateTestPublication();
            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            Publications.WriteToDB(p, DB, ptc, new string[] { "eng" });

            // Verify the publication has been added
            DataTable Results = DB.ExecuteQuery(
                @"SELECT Journal, Year, Authors, Month, Day, Title, Volume,
                         Issue, Pages, PubType, PubTypeCategoryID
                    FROM Publications
                   WHERE PMID = 15904469"
                );

            Assert.IsTrue(Results.Rows[0]["Year"].Equals(2005));
            Assert.IsTrue(Results.Rows[0]["Authors"].Equals(4));
            Assert.IsTrue(Results.Rows[0]["Year"].Equals(2005));
            Assert.IsTrue(Results.Rows[0]["Month"].Equals("May"));
            Assert.IsTrue(Results.Rows[0]["Day"].Equals(DBNull.Value));
            Assert.IsTrue(Results.Rows[0]["Title"].Equals("Charcoal cigarette filters and lung cancer risk in Aichi Prefecture, Japan."));
            Assert.IsTrue(Results.Rows[0]["Volume"].Equals("96"));
            Assert.IsTrue(Results.Rows[0]["Issue"].Equals("5"));
            Assert.IsTrue(Results.Rows[0]["Pages"].Equals("283-7"));
            Assert.IsTrue(Results.Rows[0]["PubType"].Equals("Clinical Trial"));
            Assert.IsTrue(Results.Rows[0]["PubTypeCategoryID"].Equals((short)1));


            // Verify the authors
            Assert.IsTrue(DB.GetIntValue("SELECT Count(*) FROM PublicationAuthors") == 4);
            Results = DB.ExecuteQuery("SELECT PMID, Position, Author, First, Last FROM PublicationAuthors ORDER BY Position");
            Assert.IsTrue(Results.Rows[0]["PMID"].Equals(15904469));
            Assert.IsTrue(Results.Rows[1]["PMID"].Equals(15904469));
            Assert.IsTrue(Results.Rows[2]["PMID"].Equals(15904469));
            Assert.IsTrue(Results.Rows[3]["PMID"].Equals(15904469));
            Assert.IsTrue(Results.Rows[0]["Position"].Equals(1));
            Assert.IsTrue(Results.Rows[1]["Position"].Equals(2));
            Assert.IsTrue(Results.Rows[2]["Position"].Equals(3));
            Assert.IsTrue(Results.Rows[3]["Position"].Equals(4));
            Assert.IsTrue(Results.Rows[0]["Author"].ToString() == "Muscat JE");
            Assert.IsTrue(Results.Rows[1]["Author"].ToString() == "Takezaki T");
            Assert.IsTrue(Results.Rows[2]["Author"].ToString() == "Tajima K");
            Assert.IsTrue(Results.Rows[3]["Author"].ToString() == "Stellman SD");
            Assert.IsTrue(Results.Rows[0]["First"].Equals((short)1));
            Assert.IsTrue(Results.Rows[1]["First"].Equals((short)0));
            Assert.IsTrue(Results.Rows[2]["First"].Equals((short)0));
            Assert.IsTrue(Results.Rows[3]["First"].Equals((short)0));
            Assert.IsTrue(Results.Rows[0]["Last"].Equals((short)0));
            Assert.IsTrue(Results.Rows[1]["Last"].Equals((short)0));
            Assert.IsTrue(Results.Rows[2]["Last"].Equals((short)0));
            Assert.IsTrue(Results.Rows[3]["Last"].Equals((short)1));

            // Verifying the MeSH headings
            // Note the join to PublicationMeSHHeadings to make sure it was populated properly
            Assert.IsTrue(DB.GetIntValue("SELECT Count(*) FROM PublicationMeSHHeadings WHERE PMID = " + p.PMID.ToString()) == 17);
            Results = DB.ExecuteQuery(
                @"SELECT m.Heading 
                    FROM MeSHHeadings m, PublicationMeSHHeadings p
                   WHERE p.MeSHHeadingID = m.ID
                     AND p.PMID = " + p.PMID.ToString()
                );
            Assert.IsTrue(Results.Rows.Count == 17);
            Assert.IsTrue(Results.Rows[0]["Heading"].ToString() == "Adult");
            Assert.IsTrue(Results.Rows[5]["Heading"].ToString() == "Female");
            Assert.IsTrue(Results.Rows[9]["Heading"].ToString() == "Lung Neoplasms/*etiology/pathology");
            Assert.IsTrue(Results.Rows[16]["Heading"].ToString() == "Smoking/*adverse effects");

            // Verify the grants
            Assert.IsTrue(DB.GetIntValue("SELECT Count(*) FROM PublicationGrants WHERE PMID = " + p.PMID.ToString()) == 2);
            Results = DB.ExecuteQuery(
                @"SELECT GrantID
                    FROM PublicationGrants
                   WHERE PMID = " + p.PMID.ToString() + " ORDER BY GrantID ASC"
                );
            Assert.IsTrue(Results.Rows[0]["GrantID"].ToString() == "CA-17613/CA/NCI");
            Assert.IsTrue(Results.Rows[1]["GrantID"].ToString() == "CA-68387/CA/NCI");
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Harvest each of the publications in the people file
        /// </summary>
        /// <param name="PeopleFile">Filename of the people file</param>
        /// <param name="PublicationTypeFile">Filename of publication type file</param>
        /// <param name="ContinueFromInterruption">True if continuing from a previously interrupted harvest</param>
        public void Harvest(string PeopleFile, string PublicationTypeFile, bool ContinueFromInterruption)
        {
            // First verify that the files exist
            if (!File.Exists(PeopleFile))
            {
                MessageBox.Show("The People file '" + PeopleFile + "' does not exist", "People file not found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (!File.Exists(PublicationTypeFile))
            {
                MessageBox.Show("The Publication Type file '" + PublicationTypeFile + "' does not exist", "Publication Type file not found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }


            UpdateDatabaseStatus();
            if (ContinueFromInterruption)
            {
                AddLogEntry("Continuing interrupted harvest");
            }
            else
            {
                AddLogEntry("Beginning harvesting");
            }

            // Reset lastDSNSelected to make sure that the next check for interrupted data is NOT skipped
            lastDSNSelected = "";

            // Initialize the harvester
            Harvester harvester;
            Database  DB;

            // Initialize objects
            try
            {
                DB        = new Database(DSN.Text);
                harvester = new Harvester(DB);

                // Set the language restriction
                string[] Languages;
                if (LanguageList.Text != "")
                {
                    Languages           = LanguageList.Text.Split(',');
                    harvester.Languages = Languages;
                    foreach (string Language in Languages)
                    {
                        AddLogEntry("Adding language restriction: " + Language);
                    }
                }
                else
                {
                    AddLogEntry("No language restriction added");
                }
            }
            catch (Exception ex)
            {
                AddLogEntryWithErrorBox(ex.Message, "Unable to begin harvesting");
                return;
            }

            // Initializethe database
            try
            {
                if (!ContinueFromInterruption)
                {
                    AddLogEntry("Initializing the database");
                    harvester.CreateTables();
                    UpdateDatabaseStatus();
                }
            }
            catch (Exception ex)
            {
                AddLogEntryWithErrorBox(ex.Message, "Unable to initialize database");
                return;
            }


            PublicationTypes pubTypes;

            if (ContinueFromInterruption)
            {
                // If we're continuing, read the publication types from the databse
                try
                {
                    AddLogEntry("Reading publication types from the database");
                    pubTypes = new PublicationTypes(DB);
                }
                catch (Exception ex)
                {
                    AddLogEntryWithErrorBox(ex.Message, "Unable to read publication types");
                    return;
                }
                // Remove any data left over from the interruption
                if (ContinueFromInterruption)
                {
                    AddLogEntry("Removing any data left over from the previous interruption");
                    harvester.ClearDataAfterInterruption();
                }
                UpdateDatabaseStatus();
            }
            else
            {
                // Read the publication types from the file and write them to the database
                try
                {
                    AddLogEntry("Writing publication types to database");
                    pubTypes = new PublicationTypes(Path.GetDirectoryName(PublicationTypeFile), Path.GetFileName(PublicationTypeFile));
                    pubTypes.WriteToDB(DB);
                    UpdateDatabaseStatus();
                }
                catch (Exception ex)
                {
                    AddLogEntryWithErrorBox(ex.Message, "Unable to read publication types");
                    return;
                }

                // Read the people
                try
                {
                    AddLogEntry("Reading people from " + Path.GetFileName(PeopleFile) + " and writing them to the database");
                    harvester.ImportPeople(PeopleFile);
                    UpdateDatabaseStatus();
                }
                catch (Exception ex)
                {
                    AddLogEntryWithErrorBox(ex.Message, "Unable to read the people from " + Path.GetFileName(PeopleFile));
                    return;
                }
            }


            // Make an anonymous callback function that keeps track of the callback data
            Harvester.GetPublicationsStatus StatusCallback = delegate(int number, int total, int averageTime)
            {
                // No need to update the progress bar for this -- it leads to a messy-looking UI because it's also updated for the person total
                // toolStripProgressBar1.Minimum = 0;
                // toolStripProgressBar1.Maximum = total;
                // toolStripProgressBar1.Value = number;
                toolStripStatusLabel1.Text = "Reading publication " + number.ToString() + " of " + total.ToString() + " (" + averageTime.ToString() + " ms average)";
                UpdateDatabaseStatus();
                Application.DoEvents();
            };

            // Make an anonymous callback function that logs any messages passed back
            Harvester.GetPublicationsMessage MessageCallback = delegate(string Message, bool StatusBarOnly)
            {
                if (StatusBarOnly)
                {
                    toolStripStatusLabel1.Text = Message;
                    //this.Refresh();
                    //statusStrip1.Refresh();
                    Application.DoEvents();
                }
                else
                {
                    AddLogEntry(Message);
                }
            };

            // Make an anonymous callback function to return the value of Interrupt for CheckForInterrupt
            Harvester.CheckForInterrupt InterruptCallback = delegate()
            {
                return(InterruptClicked);
            };

            // Get each person's publications and write them to the database
            NCBI ncbi = new NCBI("medline");

            if (NCBI.ApiKeyExists)
            {
                AddLogEntry("Using API key: " + NCBI.ApiKeyPath);
            }
            else
            {
                AddLogEntry("Performance is limited to under 3 requests per second.");
                AddLogEntry("Consider pasting an API key into " + NCBI.ApiKeyPath);
                AddLogEntry("Or set the NCBI_API_KEY_FILE environemnt variable to the API key file path");
                AddLogEntry("For more information, see https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/");
            }
            People people = new People(DB);
            int    totalPeopleInPersonList = people.PersonList.Count;
            int    numberOfPeopleProcessed = 0;

            toolStripProgressBar1.Minimum = 0;
            toolStripProgressBar1.Maximum = totalPeopleInPersonList;

            foreach (Person person in people.PersonList)
            {
                numberOfPeopleProcessed++;
                try
                {
                    // If continuing from interruption, only harvest unharvested people
                    if ((!ContinueFromInterruption) || (!person.Harvested))
                    {
                        AddLogEntry("Getting publications for " + person.Last + " (" + person.Setnb + "), number " + numberOfPeopleProcessed.ToString() + " of " + totalPeopleInPersonList.ToString());
                        toolStripProgressBar1.Value = numberOfPeopleProcessed;
                        double AverageMilliseconds;
                        int    NumPublications = harvester.GetPublications(ncbi, pubTypes, person, StatusCallback, MessageCallback, InterruptCallback, out AverageMilliseconds);
                        if (InterruptClicked)
                        {
                            AddLogEntry("Publication harvesting was interrupted");
                            UpdateDatabaseStatus();
                            return;
                        }
                        AddLogEntry("Wrote " + NumPublications.ToString() + " publications, average write time " + Convert.ToString(Math.Round(AverageMilliseconds, 1)) + " ms");
                        UpdateDatabaseStatus();
                    }
                    else
                    {
                        AddLogEntry("Already retrieved publications for " + person.Last + " (" + person.Setnb + ")");
                    }
                }
                catch (Exception ex)
                {
                    AddLogEntry("An error occurred while reading publications for " + person.Last + " (" + person.Setnb + "): " + ex.Message);
                }
            }

            AddLogEntry("Finished reading publications");
            UpdateDatabaseStatus();
        }
Ejemplo n.º 16
0
        public void TestMeSHHeadingReport()
        {
            // Set up the database with test publications (and don't forget to add the
            // publication types!)
            DB = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            PublicationTypes PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            PubTypes.WriteToDB(DB);
            reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls");
            Assert.IsTrue(reports.Weights.Count == 10);
            TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22);

            // Write the MeSH Heading report
            StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\MeSHHeadingReport.csv");

            Reports.ReportStatus StatusCallback = delegate(int number, int total, Person person, bool ProgressBarOnly)
            {
                //
            };
            Reports.ReportMessage MessageCallback = delegate(string Message)
            {
                //
            };
            reports.MeSHHeadingReport(writer, StatusCallback, MessageCallback);
            writer.Close();

            // Verify that the MeSH headings were written properly

            // Read the rows back from the file
            string ConnectionString =
                "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="
                + AppDomain.CurrentDomain.BaseDirectory + ";";
            OdbcConnection  Connection  = new OdbcConnection(ConnectionString);
            OdbcDataAdapter DataAdapter = new OdbcDataAdapter
                                              ("SELECT * FROM [MeSHHeadingReport.csv]", Connection);
            DataTable Results = new DataTable();
            int       Rows    = DataAdapter.Fill(Results);

            Connection.Close();

            int numChecked = 0;

            // Check a few selected results
            foreach (DataRow Row in Results.Rows)
            {
                string Setnb   = Row[0].ToString();
                int    Year    = Convert.ToInt32(Row[1]);
                string Heading = Row[2].ToString();
                int    Count   = Convert.ToInt32(Row[3]);

                switch (Setnb)
                {
                case "A6009400":     // Van Eys
                    if ((Year == 1998) && (Heading == "Humans"))
                    {
                        Assert.IsTrue(Count == 2);
                        numChecked++;
                    }
                    if ((Year == 1998) && (Heading == "Child"))
                    {
                        Assert.IsTrue(Count == 1);
                        numChecked++;
                    }
                    if ((Year == 2001) && (Heading == "Humans"))
                    {
                        Assert.IsTrue(Count == 1);
                        numChecked++;
                    }
                    break;

                case "A5702471":     // Guillemin
                    if ((Year == 2005) && (Heading == "Hypothalamic Hormones/*physiology"))
                    {
                        Assert.IsTrue(Count == 1);
                        numChecked++;
                    }
                    break;
                }
            }
            Assert.IsTrue(numChecked == 4);

            File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\MeSHHeadingReport.csv");
        }
Ejemplo n.º 17
0
        public void TestSkipSetnbs()
        {
            // Set up the database with test publications (and don't forget to add the
            // publication types!)
            DB = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            PublicationTypes PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            PubTypes.WriteToDB(DB);
            reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls");
            Assert.IsTrue(reports.Weights.Count == 10);
            TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22);
            people = new People(DB);


            Reports.ReportStatus StatusCallback = delegate(int number, int total, Person person, bool ProgressBarOnly)
            {
                //
            };
            Reports.ReportMessage MessageCallback = delegate(string Message)
            {
                //
            };

            // Set up the Setnbs to skip
            ArrayList SetnbsToSkip = new ArrayList();

            SetnbsToSkip.Add("A5401532");
            SetnbsToSkip.Add("A6009400");

            // Verify that the people report skips the setnbs
            StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\TestSkipSetnbs.csv");

            reports.PeopleReport(SetnbsToSkip, writer, StatusCallback, MessageCallback);
            writer.Close();
            StreamReader reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\TestSkipSetnbs.csv");
            string       Line   = reader.ReadLine(); // skip the header row

            while ((Line = reader.ReadLine()) != null)
            {
                Assert.IsFalse(Line.StartsWith("A5401532"));
                Assert.IsFalse(Line.StartsWith("A6009400"));
            }
            reader.Close();

            // Verify that the people report skips the setnbs
            writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\TestSkipSetnbs.csv", false);
            reports.PubsReport(SetnbsToSkip, writer, StatusCallback, MessageCallback);
            writer.Close();
            reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\TestSkipSetnbs.csv");
            Line   = reader.ReadLine(); // skip the header row
            while ((Line = reader.ReadLine()) != null)
            {
                Assert.IsFalse(Line.StartsWith("A5401532"));
                Assert.IsFalse(Line.StartsWith("A6009400"));
            }
            reader.Close();

            File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\TestSkipSetnbs.csv");
        }
Ejemplo n.º 18
0
        public void TestMiddleAuthor()
        {
            string MedlineData = @"PMID- 14332364
OWN - NLM
STAT- OLDMEDLINE
DA  - 19651101
DCOM- 19961201
LR  - 20051116
PUBM- Print
IS  - 0002-922X (Print)
VI  - 110
DP  - 1965 Sep
TI  - CONGENITAL SCALP DEFECTS IN TWIN SISTERS.
PG  - 293-5
FAU - HODGMAN, J E
AU  - HODGMAN JE
FAU - MATHIES, A W Jr
AU  - MATHIES AW Jr
FAU - LEVAN, N E
AU  - LEVAN NE
LA  - eng
PT  - Journal Article
PL  - UNITED STATES
TA  - Am J Dis Child
JT  - American journal of diseases of children (1960)
JID - 0370471
SB  - OM
MH  - *Abnormalities
MH  - *Diseases in Twins
MH  - *Infant, Newborn
MH  - *Scalp
OTO - NLM
OT  - *ABNORMALITIES
OT  - *DISEASES IN TWINS
OT  - *INFANT, NEWBORN
OT  - *SCALP
EDAT- 1965/09/01
MHDA- 1965/09/01 00:01
PST - ppublish
SO  - Am J Dis Child. 1965 Sep;110:293-5.";

            // Add a person to the database
            Database DB      = new Database("Publication Harvester Unit Test");
            Person   Mathies = new Person("A5703161", "Allan", "W", "MATHIES", false,
                                          new String[] { "MATHIES AW Jr" }, "MATHIES AW Jr[au]");

            // Create the publication
            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );
            Publications Pubs = new Publications(MedlineData, ptc);

            Assert.IsTrue(Pubs.PublicationList.Length == 1);
            Publication Pub = Pubs.PublicationList[0];

            Assert.IsTrue(Pub.Authors[1] == "MATHIES AW Jr");

            // Clear the database
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();

            // Write the person and publication to the database
            // NOTE: The author position is determined in WritePeoplePublicationsToDB()
            PublicationTypes PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            Mathies.WriteToDB(DB);
            Publications.WriteToDB(Pub, DB, PubTypes, new string[] { "eng" });
            Publications.WritePeoplePublicationsToDB(DB, Mathies, Pub);

            // Verify that Mathies is the middle author, not the second author
            Publications PubsFromDB = new Publications(DB, Mathies, false);

            Assert.IsTrue(PubsFromDB.PublicationList.Length == 1);
            Assert.IsTrue(PubsFromDB.PublicationList[0].PMID == 14332364);
            Harvester.AuthorPositions PositionType;
            Assert.IsTrue(Publications.GetAuthorPosition(DB, 14332364, Mathies, out PositionType, "PeoplePublications") == 2);
            Assert.IsTrue(PositionType == Harvester.AuthorPositions.Middle);
        }
        /// <summary>
        /// Check a publication against the filter
        /// </summary>
        /// <param name="publication">Publication to check</param>
        /// <param name="linkRanking">Link ranking for the publication</param>
        /// <param name="referencePublication">Reference publication to compare against</param>
        /// <param name="publicationTypes">PublicationTypes object for the current database</param>
        /// <returns>True if the publication matches the filter, false otherwise</returns>
        public bool FilterPublication(Publication publication, int linkRanking, Publication referencePublication, PublicationTypes publicationTypes)
        {
            if (SameJournal && (publication.Journal != referencePublication.Journal))
            {
                return(false);
            }

            if (PubWindowLowerBound.HasValue && (referencePublication.Year - PubWindowLowerBound > publication.Year))
            {
                return(false);
            }

            if (PubWindowUpperBound.HasValue && (referencePublication.Year + PubWindowUpperBound < publication.Year))
            {
                return(false);
            }

            if (linkRanking > MaximumLinkRanking)
            {
                return(false);
            }

            if (((IncludeCategories != null) && (IncludeCategories.Count() > 0)) &&
                ((String.IsNullOrEmpty(publication.PubType) ||
                  !IncludeCategories.Contains(publicationTypes.GetCategoryNumber(publication.PubType)))))
            {
                return(false);
            }

            if ((IncludeLanguages != null) && (IncludeLanguages.Count() > 0) &&
                (String.IsNullOrEmpty(publication.Language) ||
                 !IncludeLanguages.Contains(publication.Language)))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 20
0
        public void TestPubsReportRow()
        {
            // Set up the database with test publications (and don't forget to add the
            // publication types!)
            DB = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            PublicationTypes PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            PubTypes.WriteToDB(DB);
            reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls");
            Assert.IsTrue(reports.Weights.Count == 10);
            TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22);
            people = new People(DB);


            foreach (Person person in people.PersonList)
            {
                Publications pubs = new Publications(DB, person, false);

                if (pubs.PublicationList != null)
                {
                    foreach (Publication pub in pubs.PublicationList)
                    {
                        DataRow Row = WriteAndReadBackCSVRow(reports.PubsReportRow(person, pub));

                        switch (pub.PMID)
                        {
                        case 15249795:
                            // 0. setnb
                            Assert.IsTrue(Row.ItemArray[0].ToString() == "A5401532");

                            // 1. pmid
                            Assert.IsTrue(Row.ItemArray[1].ToString() == "15249795");

                            // 2. journal_name
                            Assert.IsTrue(Row.ItemArray[2].ToString() == "J Clin Hypertens (Greenwich)");

                            // 3. year
                            Assert.IsTrue(Row.ItemArray[3].ToString() == "2004");

                            // 4. Month
                            Assert.IsTrue(Row.ItemArray[4].ToString() == "Jul");

                            // 5. day
                            Assert.IsTrue(Row.ItemArray[5].ToString() == "");

                            // 6. title
                            Assert.IsTrue(Row.ItemArray[6].ToString() == "Interview with Louis Tobian, MD. Interview by Marvin Moser.");

                            // 7. Volume
                            Assert.IsTrue(Row.ItemArray[7].ToString() == "6");

                            // 8. issue
                            Assert.IsTrue(Row.ItemArray[8].ToString() == "7");

                            // 9. position
                            Assert.IsTrue(Row.ItemArray[9].ToString() == "1");

                            // 10. nbauthors
                            Assert.IsTrue(Row.ItemArray[10].ToString() == "1");

                            // 11. Bin
                            Assert.IsTrue(Row.ItemArray[11].ToString() == "0");

                            // 12. Pages
                            Assert.IsTrue(Row.ItemArray[12].ToString() == "391-2");

                            // 13. Publication_type
                            Assert.IsTrue(Row.ItemArray[13].ToString() == "Historical Article");


                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        public void TestEntireReport()
        {
            string Setnb = "";

            // Set up the database with test publications (and don't forget to add the
            // publication types!)
            DB = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            PublicationTypes PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            PubTypes.WriteToDB(DB);
            reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls");
            Assert.IsTrue(reports.Weights.Count == 10);
            TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22);
            people = new People(DB);


            // Write the report
            StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\TestEntireReport.csv");

            Reports.ReportStatus StatusCallback   = delegate(int number, int total, Person person, bool ProgressBarOnly) {
                //
            };
            Reports.ReportMessage MessageCallback = delegate(string Message)
            {
                //
            };
            reports.PeopleReport(null, writer, StatusCallback, MessageCallback);
            writer.Close();

            // Read the report into an array
            var lines = File.ReadAllLines($"{AppDomain.CurrentDomain.BaseDirectory}\\TestEntireReport.csv")
                        .Select(line => line.Split(new char[] { ',' }));
            var header = lines.First();
            var data   = lines.Skip(1).ToList();

            Assert.AreEqual(85, data.Count);

            string ReportData(string setnb, string year, string column)
            {
                var index = Array.IndexOf(header, column);
                var row   = data.Where(line => line[0] == setnb && line[1] == year);

                Assert.AreEqual(1, row.Count(), $"Unable to find setnb={setnb} year={year} in TestEntireReport.csv");
                return(row.First()[index]);
            }

            var q = ReportData("A5401532", "1997", "wghtd_pubcount_pos1");

            // Read the report file that was generated by hand (TestEntireReport_Data.xls)
            // and check each value against the report that was generated by Reports()
            string[] Columns =
            {
                "setnb",                    "year",                   "pubcount",               "wghtd_pubcount",       "pubcount_pos1",
                "wghtd_pubcount_pos1",      "pubcount_posN",          "wghtd_pubcount_posN",
                "pubcount_posM",            "wghtd_pubcount_posM",    "pubcount_posNTL",
                "wghtd_pubcount_posNTL",    "pubcount_pos2",          "wghtd_pubcount_pos2",
                "123pubcount",              "wghtd_123pubcount",      "123pubcount_pos1",
                "wghtd_123pubcount_pos1",   "123pubcount_posN",       "wghtd_123pubcount_posN",
                "123pubcount_posM",         "wghtd_123pubcount_posM", "123pubcount_posNTL",
                "wghtd_123pubcount_posNTL", "123pubcount_pos2",       "wghtd_123pubcount_pos2",
                "1pubcount",                "wghtd_1pubcount",        "1pubcount_pos1",         "wghtd_1pubcount_pos1",
                "1pubcount_posN",           "wghtd_1pubcount_posN",   "1pubcount_posM",
                "wghtd_1pubcount_posM",     "1pubcount_posNTL",       "wghtd_1pubcount_posNTL",
                "1pubcount_pos2",           "wghtd_1pubcount_pos2",   "2pubcount",              "wghtd_2pubcount",
                "2pubcount_pos1",           "wghtd_2pubcount_pos1",   "2pubcount_posN",
                "wghtd_2pubcount_posN",     "2pubcount_posM",         "wghtd_2pubcount_posM",
                "2pubcount_posNTL",         "wghtd_2pubcount_posNTL", "2pubcount_pos2",
                "wghtd_2pubcount_pos2",     "3pubcount",              "wghtd_3pubcount",        "3pubcount_pos1",
                "wghtd_3pubcount_pos1",     "3pubcount_posN",         //"wghtd_3pubcount_posN",
                "3pubcount_posM",           "wghtd_3pubcount_posM",   "3pubcount_posNTL",
                "wghtd_3pubcount_posNTL",   "3pubcount_pos2",         "wghtd_3pubcount_pos2",
                "4pubcount",                "wghtd_4pubcount",        "4pubcount_pos1",         "wghtd_4pubcount_pos1",
                "4pubcount_posN",           "wghtd_4pubcount_posN",   "4pubcount_posM",
                "wghtd_4pubcount_posM",     "4pubcount_posNTL",       "wghtd_4pubcount_posNTL",
                "4pubcount_pos2",           "wghtd_4pubcount_pos2"
            };

            DataTable HandGeneratedData = NpoiHelper.ReadExcelFileToDataTable(AppDomain.CurrentDomain.BaseDirectory +
                                                                              "\\Unit Tests\\TestReports", "TestEntireReport_Data.xls");

            Assert.AreEqual(HandGeneratedData.Rows.Count, 85);

            var valuesChecked = 0;

            for (int RowNum = 0; RowNum < HandGeneratedData.Rows.Count; RowNum++)
            {
                // Find the rows in the hand-generated data and the report
                DataRow HandGeneratedRow = HandGeneratedData.Rows[RowNum];
                Setnb = HandGeneratedRow[0].ToString();
                int Year = Convert.ToInt32(HandGeneratedRow[1]);

                for (int i = 2; i < Columns.Length; i++)
                {
                    valuesChecked++;
                    String columnName    = Columns[i];
                    var    actualValue   = ReportData(Setnb, Year.ToString(), columnName);
                    string expectedValue = HandGeneratedRow[columnName].ToString();
                    Assert.AreEqual(expectedValue, actualValue, Setnb + "/" + Year.ToString() + "/" + columnName + " -- hand generated has " + expectedValue + ", report has" + actualValue);
                }
            }

            Assert.AreEqual((HandGeneratedData.Rows.Count) * (Columns.Length - 2), valuesChecked);

            // Use BackupReportAndGetSetnbs to back up the report -- check that it
            // returns the correct list of Setnbs and removes the last one from
            // the file. The last Setnb should still be in Setnb.
            ArrayList Setnbs = Reports.BackupReportAndGetSetnbs(AppDomain.CurrentDomain.BaseDirectory + "\\TestEntireReport.csv");
            // Read the backup file that was created, make sure that the last setnb in the
            // file isn't contained and the others are
            StreamReader reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\TestEntireReport.csv.bak");
            string       Line   = reader.ReadLine();   //skip the header row

            while ((Line = reader.ReadLine()) != null) // Find the last setnb in the original file
            {
                Setnb = Line.Substring(0, 8);
            }
            string RemovedSetnb = Setnb;

            Assert.IsFalse(Setnbs.Contains(RemovedSetnb));
            reader.Close();

            // Verify that the new file contains only the other setnbs
            Assert.IsTrue(Setnbs.Count == 3);
            Assert.IsFalse(Setnbs.Contains(RemovedSetnb));
            reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\TestEntireReport.csv");
            Line   = reader.ReadLine(); //skip the header row
            while ((Line = reader.ReadLine()) != null)
            {
                Setnb = Line.Substring(0, 8);
                Assert.IsTrue(Setnbs.Contains(Setnb));
                Assert.IsFalse(Setnb == RemovedSetnb);
            }
            reader.Close();

            // Delete the temporary files
            File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\TestEntireReport.csv");
            File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\TestEntireReport.csv.bak");
        }
        /// <summary>
        /// Use the tests from TestColleagues to set up the database,
        /// then find the colleagues, get their publications and
        /// remove false colleagues.
        ///
        /// This is a static void so that it can be called by other tests.
        /// </summary>
        public static void DoSetUp(out Database DB, out Harvester harvester, out PublicationTypes PubTypes, out NCBI ncbi, string[] Languages)
        {
            // First recreate the database
            DB = new Database("Colleague Generator Unit Test");
            ColleagueFinder.CreateTables(DB);

            // Then use the test fixture setup in TestColleagues to populate it
            TestColleagues testColleagues = new TestColleagues();

            testColleagues.TestColleaguesSetUp();

            // Write the publication types to the database
            PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Test Data\\TestColleagues",
                "PublicationTypes.csv"
                );
            PubTypes.WriteToDB(DB);

            // Create the other objects from the database
            harvester = new Harvester(DB);
            Roster roster = new Roster(AppDomain.CurrentDomain.BaseDirectory + "\\Test Data\\TestRoster\\testroster.csv");

            ncbi = new MockNCBI("Medline");

            // Find the colleagues and publications
            ColleagueFinder finder = new ColleagueFinder(DB, roster, ncbi, null);
            People          people = new People(DB);

            foreach (Person person in people.PersonList)
            {
                Person[] found = finder.FindPotentialColleagues(person);
                if (found != null)
                {
                    finder.GetColleaguePublications(found, new string[] { "eng" }, new List <int> {
                        1, 2, 3
                    });
                }
            }

            // Remove false colleagues
            ColleagueFinder.RemoveFalseColleagues(DB, null, "PeoplePublications");


            // Create the extra articles for Bunn and Tobian.
            // Verify that Bunn and Tobian have five articles in common, with years
            // ranging from 1993 to 2001.
            CreateExtraArticlesForTobianAndBunn(DB, PubTypes, Languages);
            DataTable Result = DB.ExecuteQuery(
                @"SELECT p.Year, p.PMID, pp.PositionType AS StarPositionType, 
                       cp.PositionType AS ColleaguePositionType, p.Journal
                  FROM Publications p, ColleaguePublications cp, PeoplePublications pp
                 WHERE pp.Setnb = 'A5401532'
                   AND cp.Setnb = 'A4800524'
                   AND p.PMID = pp.PMID
                   AND p.PMID = cp.PMID
                 ORDER BY p.Year ASC");

            Assert.AreEqual(Result.Rows.Count, 5);
            Assert.AreEqual(Result.Rows[0]["Year"], 1993);
            Assert.AreEqual(Result.Rows[4]["Year"], 2001);
        }
Ejemplo n.º 23
0
        public void TestPeopleReportRows()
        {
            // Set up the database with test publications (and don't forget to add the
            // publication types!)
            DB = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            PublicationTypes PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            PubTypes.WriteToDB(DB);
            reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls");
            Assert.IsTrue(reports.Weights.Count == 10);
            TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22);
            people = new People(DB);


            foreach (Person person in people.PersonList)
            {
                Publications pubs = new Publications(DB, person, false);
                switch (person.Setnb)
                {
                case "A6009400":
                    // Van Eys has two publications in 1998, both have zero weight
                    DataRow Row = WriteAndReadBackCSVRow(reports.ReportRow(person, pubs, 1998));

                    Assert.IsTrue(Row.ItemArray.Length == 74);
                    Assert.IsTrue(Row.ItemArray[0].ToString() == "A6009400");
                    Assert.IsTrue(Row.ItemArray[1].ToString() == "1998");

                    // Verify that all values are zero, except for pubcount (#3),
                    // pubcount_pos1 (#5), 123pubcount (#15), 123pubcount_pos1 (#17),
                    // 3pubcount (#51), 3pubcount_pos1 (#53)
                    for (int i = 2; i <= 73; i++)
                    {
                        if ((i == 2) || (i == 4) || (i == 14) || (i == 16) ||
                            (i == 50) || (i == 52))
                        {
                            Assert.IsTrue(Row.ItemArray[i].ToString() == "2", "Failed at i == " + i.ToString());
                        }
                        else
                        {
                            Assert.IsTrue(Row.ItemArray[i].ToString() == "0", "Failed at i == " + i.ToString());
                        }
                    }
                    break;

                case "A5401532":
                    // Tobian has two publications in 1997 of type 3 with a
                    // combined weight of 4.602
                    Row = WriteAndReadBackCSVRow(reports.ReportRow(person, pubs, 1997));

                    Assert.IsTrue(Row.ItemArray.Length == 74);
                    Assert.IsTrue(Row.ItemArray[0].ToString() == "A5401532");
                    Assert.IsTrue(Row.ItemArray[1].ToString() == "1997");

                    // Verify that all values are zero, except for pubcount (#3),
                    // pubcount_pos1 (#5), 123pubcount (#15), 123pubcount_pos1 (#17),
                    // 3pubcount (#51), 3pubcount_pos1 (#53), which should be 2
                    //
                    // and wghtd_pubcount (#4), wghtd_pubcount_pos1 (#6),
                    // wghtd_123pubcount (#16), wghtd_123pubcount_pos1 (#18),
                    // wghtd_3pubcount (#52), wghtd_3pubcount_pos1 (#54),
                    // which should be 4.602
                    for (int i = 2; i <= 73; i++)
                    {
                        if ((i == 2) || (i == 4) || (i == 14) || (i == 16) ||
                            (i == 50) || (i == 52))
                        {
                            Assert.IsTrue(Row.ItemArray[i].ToString() == "2", "Failed at i == " + i.ToString());
                        }
                        else if ((i == 3) || (i == 5) || (i == 15) || (i == 17) ||
                                 (i == 51) || (i == 53))
                        {
                            Assert.IsTrue(Row.ItemArray[i].ToString() == "4.602", "Failed at i == " + i.ToString());
                        }
                        else
                        {
                            Assert.IsTrue(Row.ItemArray[i].ToString() == "0", "Failed at i == " + i.ToString());
                        }
                    }
                    break;
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Add a row to ColleaguePublications for a person and publication
        /// </summary>
        /// <param name="DB">Database to write to</param>
        /// <param name="person">Colleague who is the author of the publication</param>
        /// <param name="publication">Publication to write</param>
        /// <returns>True if the publication really matches the colleague, False otherwise</returns>
        public static bool WriteColleaguePublicationsToDB(Database DB, Person Colleague, Publication publication, PublicationTypes pubTypes, string[] Languages)
        {
            ArrayList Parameters;

            // Write the publication to the database
            Publications.WriteToDB(publication, DB, pubTypes, Languages);

            if (publication.Authors == null)
            {
                return(false);
            }

            int AuthorPosition = 0;

            for (int i = 1; (AuthorPosition == 0) && (i <= publication.Authors.Length); i++)
            {
                foreach (string name in Colleague.Names)
                {
                    if (StringComparer.CurrentCultureIgnoreCase.Equals(
                            publication.Authors[i - 1], name.ToUpper()
                            ))
                    {
                        AuthorPosition = i;
                    }
                }
            }

            // If AuthorPosition is still 0, the colleague wasn't actually found in the
            // publication, so return false without writing the publication to the database.
            if (AuthorPosition == 0)
            {
                return(false);
            }

            // From the SRS -- definition of position type:
            // •	1 if the person is the first author
            // •	2 if the person is the last author
            // •	3 if the person is the second author -- only if # authors >= 5
            // •	4 if the person is the next-to-last author -- only if # authors >= 5
            // •	5 if the person is in the middle (and there are five or more authors for the publication)
            Harvester.AuthorPositions PositionType;
            if (AuthorPosition == 1)
            {
                PositionType = Harvester.AuthorPositions.First;
            }
            else if (AuthorPosition == publication.Authors.Length)
            {
                PositionType = Harvester.AuthorPositions.Last;
            }
            else if ((AuthorPosition == 2) && (publication.Authors.Length >= 5))
            {
                PositionType = Harvester.AuthorPositions.Second;
            }
            else if ((AuthorPosition == publication.Authors.Length - 1) && (publication.Authors.Length >= 5))
            {
                PositionType = Harvester.AuthorPositions.NextToLast;
            }
            else
            {
                PositionType = Harvester.AuthorPositions.Middle;
            }

            // Write the row to ColleaguePublications
            Parameters = new ArrayList();
            Parameters.Add(Database.Parameter(Colleague.Setnb));
            Parameters.Add(Database.Parameter(publication.PMID));
            Parameters.Add(Database.Parameter(AuthorPosition));
            Parameters.Add(Database.Parameter((int)PositionType));
            DB.ExecuteNonQuery(@"INSERT INTO ColleaguePublications
                                                (Setnb, PMID, AuthorPosition, PositionType)
                                         VALUES ( ? , ? , ? , ? )", Parameters);
            return(true);
        }
Ejemplo n.º 25
0
        public void TestGrantsReport()
        {
            // Set up the database with test publications (and don't forget to add the
            // publication types!)
            DB = new Database("Publication Harvester Unit Test");
            Harvester harvester = new Harvester(DB);

            harvester.CreateTables();
            PublicationTypes PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            PubTypes.WriteToDB(DB);
            reports = new Reports(DB, AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestReports\\pubmed_jifs.xls");
            Assert.IsTrue(reports.Weights.Count == 10);
            TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22);

            // Write the grants report
            StreamWriter writer = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\GrantsReport.csv");

            reports.GrantsReport(writer);
            writer.Close();

            // Verify that the grants were written properly

            // Read the rows back from the file
            string ConnectionString =
                "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="
                + AppDomain.CurrentDomain.BaseDirectory + ";";
            OdbcConnection  Connection  = new OdbcConnection(ConnectionString);
            OdbcDataAdapter DataAdapter = new OdbcDataAdapter
                                              ("SELECT * FROM [GrantsReport.csv]", Connection);
            DataTable Results = new DataTable();
            int       Rows    = DataAdapter.Fill(Results);

            Connection.Close();

            int numChecked = 0;

            // Check a few selected results
            foreach (DataRow Row in Results.Rows)
            {
                int    Year    = Convert.ToInt32(Row[0]);
                int    PMID    = Convert.ToInt32(Row[1]);
                string GrantID = Row[2].ToString();

                switch (PMID)
                {
                case 3086749:     // Guillemin
                    numChecked++;
                    Assert.IsTrue((Year == 1986) && (
                                      (GrantID == "AM-18811/AM/NIADDK") ||
                                      (GrantID == "HD-09690/HD/NICHD") ||
                                      (GrantID == "MH-00663/MH/NIMH") ||
                                      (GrantID == "AG 03106/AG/NIA") ||
                                      (GrantID == "DK-26741/DK/NIDDK")));
                    break;

                case 9049886:     // Van Eys
                    numChecked++;
                    Assert.IsTrue((Year == 1997) && (GrantID == "RO1-CA33097/CA/NCI"));
                    break;
                }
            }
            Assert.IsTrue(numChecked == 6);

            File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\GrantsReport.csv");
        }
Ejemplo n.º 26
0
        public void ReadThreeNormalPublications()
        {
            string MedlineData;

            #region Assign MedlineData variable to contain test data
            MedlineData = @"PMID- 15904469
OWN - NLM
STAT- MEDLINE
DA  - 20050520
DCOM- 20050728
PUBM- Print
IS  - 1347-9032
VI  - 96
IP  - 5
DP  - 2005 May
TI  - Charcoal cigarette filters and lung cancer risk in Aichi Prefecture,
      Japan.
PG  - 283-7
AB  - The lung cancer mortality rate has been lower in Japan than in the United
      States for several decades. We hypothesized that this difference is due to
      the Japanese preference for cigarettes with charcoal-containing filters,
      which efficiently absorb selected gas phase components of mainstream smoke
      including the carcinogen 4-(methylnitrosamino)-1-(3-pyridyl)-1-butanone.
      We analyzed a subset of smokers (396 cases and 545 controls) from a
      case-control study of lung cancer conducted in Aichi Prefecture, Japan.
      The risk associated with charcoal filters (73% of all subjects) was
      evaluated after adjusting for age, sex, education and smoking dose. The
      odds ratio (OR) associated with charcoal compared with 'plain' cigarette
      filters was 1.2 (95% confidence intervals [CI] 0.9, 1.6). The
      histologic-specific risks were similar (e.g. OR = 1.3, 95% CI 0.9, 2.1 for
      adenocarcinoma). The OR was 1.7 (95% CI 1.1, 2.9) in smokers who switched
      from 'plain' to charcoal brands. The mean daily number of cigarettes
      smoked in subjects who switched from 'plain' to charcoal brands was 22.5
      and 23.0, respectively. The findings from this study did not indicate that
      charcoal filters were associated with an attenuated risk of lung cancer.
      As the detection of a modest benefit or risk (e.g. 10-20%) that can have
      significant public health impact requires large samples, the findings
      should be confirmed or refuted in larger studies.
AD  - Department of Health Evaluation Sciences, Penn State Cancer Institute,
      Division of Population Sciences, Penn State College of Medicine, Hershey,
      PA 17033, USA.
FAU - Muscat, Joshua E
AU  - Muscat JE
FAU - Takezaki, Toshiro
AU  - Takezaki T
FAU - Tajima, Kazuo
AU  - Tajima K
FAU - Stellman, Steven D
AU  - Stellman SD
LA  - eng
GR  - CA-17613/CA/NCI
GR  - CA-68387/CA/NCI
PT  - Clinical Trial
PT  - Journal Article
PL  - England
TA  - Cancer Sci
JID - 101168776
RN  - 16291-96-6 (Charcoal)
SB  - IM
MH  - Adult
MH  - Aged
MH  - Aged, 80 and over
MH  - Case-Control Studies
MH  - Charcoal/*adverse effects
MH  - Female
MH  - Filtration/*utilization
MH  - Humans
MH  - Japan
MH  - Lung Neoplasms/*etiology/pathology
MH  - Male
MH  - Middle Aged
MH  - Research Support, N.I.H., Extramural
MH  - Research Support, U.S. Gov't, Non-P.H.S.
MH  - Research Support, U.S. Gov't, P.H.S.
MH  - Risk Factors
MH  - Smoking/*adverse effects
EDAT- 2005/05/21 09:00
MHDA- 2005/07/29 09:00
AID - CAS045 [pii]
AID - 10.1111/j.1349-7006.2005.00045.x [doi]
PST - ppublish
SO  - Cancer Sci 2005 May;96(5):283-7.

PMID- 15856074
OWN - NLM
STAT- In-Data-Review
DA  - 20051118
PUBM- Print
IS  - 1053-4245
VI  - 15
IP  - 6
DP  - 2005 Nov
TI  - Residential environmental exposures and other characteristics associated
      with detectable PAH-DNA adducts in peripheral mononuclear cells in a
      population-based sample of adult females.
PG  - 482-90
AB  - The detection of polycyclic aromatic hydrocarbon (PAH)-DNA adducts in
      human lymphocytes may be useful as a surrogate end point for individual
      cancer risk prediction. In this study, we examined the relationship
      between environmental sources of residential PAH, as well as other
      potential factors that may confound their association with cancer risk,
      and the detection of PAH-DNA adducts in a large population-based sample of
      adult women. Adult female residents of Long Island, New York, aged at
      least 20 years were identified from the general population between August
      1996 and July 1997. Among 1556 women who completed a structured
      questionnaire, 941 donated sufficient blood (25+ ml) to allow use of a
      competitive ELISA for measurement of PAH-DNA adducts in peripheral blood
      mononuclear cells. Ambient PAH exposure at the current residence was
      estimated using geographic modeling (n=796). Environmental home samples of
      dust (n=356) and soil (n=360) were collected on a random subset of
      long-term residents (15+ years). Multivariable regression was conducted to
      obtain the best-fitting predictive models. Three separate models were
      constructed based on data from : (A) the questionnaire, including a
      dietary history; (B) environmental home samples; and (C) geographic
      modeling. Women who donated blood in summer and fall had increased odds of
      detectable PAH-DNA adducts (OR=2.65, 95% confidence interval (CI)=1.69,
      4.17; OR=1.59, 95% CI=1.08, 2.32, respectively), as did current and past
      smokers (OR=1.50, 95% CI=1.00, 2.24; OR=1.46, 95% CI=1.05, 2.02,
      respectively). There were inconsistent associations between detectable
      PAH-DNA adducts and other known sources of residential PAH, such as
      grilled and smoked foods, or a summary measure of total dietary
      benzo-[a]-pyrene (BaP) intake during the year prior to the interview.
      Detectable PAH-DNA adducts were inversely associated with increased BaP
      levels in dust in the home, but positively associated with BaP levels in
      soil outside of the home, although CIs were wide. Ambient BaP estimates
      from the geographic model were not associated with detectable PAH-DNA
      adducts. These data suggest that PAH-DNA adducts detected in a
      population-based sample of adult women with ambient exposure levels
      reflect some key residential PAH exposure sources assessed in this study,
      such as cigarette smoking.Journal of Exposure Analysis and Environmental
      Epidemiology (2005) 15, 482-490. doi:10.1038/sj.jea.7500426; published
      online 27 April 2005.
AD  - aDepartment of Epidemiology, CB#7435 McGavran-Greenberg Hall, University
      of North Carolina School of Public Health, Chapel Hill, North Carolina
      27599-7435, USA.
FAU - Shantakumar, Sumitra
AU  - Shantakumar S
FAU - Gammon, Marilie D
AU  - Gammon MD
FAU - Eng, Sybil M
AU  - Eng SM
FAU - Sagiv, Sharon K
AU  - Sagiv SK
FAU - Gaudet, Mia M
AU  - Gaudet MM
FAU - Teitelbaum, Susan L
AU  - Teitelbaum SL
FAU - Britton, Julie A
AU  - Britton JA
FAU - Terry, Mary Beth
AU  - Terry MB
FAU - Paykin, Andrea
AU  - Paykin A
FAU - Young, Tie Lan
AU  - Young TL
FAU - Wang, Lian Wen
AU  - Wang LW
FAU - Wang, Qiao
AU  - Wang Q
FAU - Stellman, Steven D
AU  - Stellman SD
FAU - Beyea, Jan
AU  - Beyea J
FAU - Hatch, Maureen
AU  - Hatch M
FAU - Camann, David
AU  - Camann D
FAU - Prokopczyk, Bogdan
AU  - Prokopczyk B
FAU - Kabat, Geoffrey C
AU  - Kabat GC
FAU - Levin, Bruce
AU  - Levin B
FAU - Neugut, Alfred I
AU  - Neugut AI
FAU - Santella, Regina M
AU  - Santella RM
LA  - eng
PT  - Journal Article
PL  - England
TA  - J Expo Anal Environ Epidemiol
JID - 9111438
SB  - IM
EDAT- 2005/04/28 09:00
MHDA- 2005/04/28 09:00
AID - 7500426 [pii]
AID - 10.1038/sj.jea.7500426 [doi]
PST - ppublish
SO  - J Expo Anal Environ Epidemiol 2005 Nov;15(6):482-90.

PMID- 15767332
OWN - NLM
STAT- MEDLINE
DA  - 20050315
DCOM- 20050725
PUBM- Print
IS  - 1055-9965
VI  - 14
IP  - 3
DP  - 2005 Mar
TI  - Influence of type of cigarette on peripheral versus central lung cancer.
PG  - 576-81
AB  - OBJECTIVES: Adenocarcinoma has replaced squamous cell carcinoma as the
      most common cell type of lung cancer in the United States. It has been
      proposed that this shift is due to the increased use of filter and
      lower-tar cigarettes, resulting in increased delivery of smoke to
      peripheral regions of the lungs, where adenocarcinoma usually occurs. We
      reviewed radiologic data to evaluate the hypothesis that tumors in smokers
      of cigarettes with lower-tar yield are more likely to occur peripherally
      than tumors in smokers of higher-yield cigarettes. METHODS: At two urban
      academic medical centers, we reviewed computed tomographic scans, chest
      radiographs, and medical records to assign tumor location (peripheral or
      central) for 330 smokers diagnosed with carcinoma of the lung between 1993
      and 1999. We compared the proportion of tumors in a peripheral versus
      central location by lifetime filter use and average lifetime tar rating (<
      21 and > or = 21 mg). RESULTS: Tumor location (69% peripheral and 31%
      central) was unrelated to cigarette filter use. Smokers of cigarettes with
      lower-tar ratings were more likely than those with higher ratings to have
      peripheral rather than central tumors (odds ratio, 1.76; 95% confidence
      interval, 0.89-3.47). When restricted to subjects with adenocarcinoma or
      squamous cell carcinoma, the odds ratio (95% confidence interval) was 2.31
      (1.05-5.08). CONCLUSIONS: Among cigarette smokers with lung cancer, use of
      cigarettes with lower-tar yield was associated with preferential
      occurrence of tumors in peripheral sites. Our findings support the
      hypothesis that changes in smoking associated with lower-tar cigarettes
      have led to a shift in the location of smoking-related lung cancer.
AD  - Department of Epidemiology, Boston University School of Public Health,
      Boston, MA 02118, USA. [email protected]
FAU - Brooks, Daniel R
AU  - Brooks DR
FAU - Austin, John H M
AU  - Austin JH
FAU - Heelan, Robert T
AU  - Heelan RT
FAU - Ginsberg, Michelle S
AU  - Ginsberg MS
FAU - Shin, Victor
AU  - Shin V
FAU - Olson, Sara H
AU  - Olson SH
FAU - Muscat, Joshua E
AU  - Muscat JE
FAU - Stellman, Steven D
AU  - Stellman SD
LA  - eng
GR  - CA-17613/CA/NCI
GR  - CA-68384/CA/NCI
PT  - Journal Article
PL  - United States
TA  - Cancer Epidemiol Biomarkers Prev
JID - 9200608
RN  - 0 (Tars)
SB  - IM
MH  - Aged
MH  - Case-Control Studies
MH  - Female
MH  - Humans
MH  - Lung Neoplasms/*etiology/*pathology
MH  - Male
MH  - Middle Aged
MH  - Odds Ratio
MH  - Research Support, N.I.H., Extramural
MH  - Research Support, U.S. Gov't, P.H.S.
MH  - Smoking/*adverse effects
MH  - Tars/*adverse effects/classification
MH  - Tomography, X-Ray Computed
EDAT- 2005/03/16 09:00
MHDA- 2005/07/26 09:00
AID - 14/3/576 [pii]
AID - 10.1158/1055-9965.EPI-04-0468 [doi]
PST - ppublish
SO  - Cancer Epidemiol Biomarkers Prev 2005 Mar;14(3):576-81.

";
            #endregion

            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            Publications mpr = new Publications(MedlineData, ptc);
            Assert.IsTrue(mpr.PublicationList.Length == 3);

            Publication p = mpr.PublicationList[0];
            Assert.AreEqual(p.PMID, 15904469);
            Assert.AreEqual(p.Year, 2005);
            Assert.IsTrue(p.Month == "May");
            Assert.IsTrue(p.Day == null);
            Assert.IsTrue(p.Title == "Charcoal cigarette filters and lung cancer risk in Aichi Prefecture, Japan.");
            Assert.IsTrue(p.Pages == "283-7");
            Assert.IsTrue(p.Journal == "Cancer Sci");
            Assert.IsTrue(p.Volume == "96");
            Assert.IsTrue(p.Issue == "5");
            Assert.IsTrue(p.Grants.Count == 2);
            Assert.IsTrue(p.Grants.Contains("CA-17613/CA/NCI"));
            Assert.IsTrue(p.Grants.Contains("CA-68387/CA/NCI"));
            Assert.IsTrue(p.PubType == "Clinical Trial");
            Assert.IsTrue(p.MeSHHeadings.Count == 17);
            Assert.IsTrue(p.MeSHHeadings.Contains("Adult"));
            Assert.IsTrue(p.MeSHHeadings.Contains("Smoking/*adverse effects"));
            Assert.IsTrue(p.Authors.Length == 4);
            Assert.IsTrue(p.Authors[0] == "Muscat JE");
            Assert.IsTrue(p.Authors[3] == "Stellman SD");

            p = mpr.PublicationList[2];
            Assert.AreEqual(p.PMID, 15767332);
            Assert.AreEqual(p.Year, 2005);
            Assert.IsTrue(p.Month == "Mar");
            Assert.IsTrue(p.Day == null);
            Assert.IsTrue(p.Title == "Influence of type of cigarette on peripheral versus central lung cancer.");
            Assert.IsTrue(p.Pages == "576-81");
            Assert.IsTrue(p.Journal == "Cancer Epidemiol Biomarkers Prev");
            Assert.IsTrue(p.Volume == "14");
            Assert.IsTrue(p.Issue == "3");
            Assert.IsTrue(p.Grants.Count == 2);
            Assert.IsTrue(p.Grants.Contains("CA-17613/CA/NCI"));
            Assert.IsTrue(p.Grants.Contains("CA-68384/CA/NCI"));
            Assert.IsTrue(p.PubType == "Journal Article");
            Assert.IsTrue(p.MeSHHeadings.Count == 13);
            Assert.IsTrue(p.MeSHHeadings.Contains("Aged"));
            Assert.IsTrue(p.MeSHHeadings.Contains("Tomography, X-Ray Computed"));
            Assert.IsTrue(p.Authors.Length == 8);
            Assert.IsTrue(p.Authors[0] == "Brooks DR");
            Assert.IsTrue(p.Authors[7] == "Stellman SD");
        }
        /// <summary>
        /// Add five extra articles to the database for Tobian and Bunn
        /// </summary>
        public static void CreateExtraArticlesForTobianAndBunn(Database DB, PublicationTypes PubTypes, string[] Languages)
        {
            // Create people objects for Tobian and Bunn
            Person Tobian = new Person("A5401532", "Louis", "", "Tobian", true,
                                       new String[] { "tobian l", "tobian l jr", "tobian lj" },
                                       "(\"tobian l\"[au] OR \"tobian l jr\"[au] OR \"tobian lj\"[au])");

            Person Bunn = new Person("A4800524", "PAUL", "A.", "BUNN", true,
                                     new String[] { "bunn p jr", "bunn pa jr", "bunn pa", "bunn p" },
                                     "((\"bunn pa jr\"[au] or \"bunn p jr\"[au]) or ((\"bunn p\"[au] or \"bunn pa\"[au]) and (lymphoma or cancer)) and 1970:2005[dp])");

            // First, add a few more publications to the colleague.
            Publication pub = new Publication();

            string[] Authors = new String[] { "TOBIAN L", "BUNN P" };
            pub.Year     = 1993;
            pub.Journal  = "Fake Journal";
            pub.Authors  = Authors;
            pub.PMID     = 22222222;
            pub.Title    = "Fake article #1";
            pub.Language = "eng";
            pub.PubType  = "Journal Article";
            Publications.WriteToDB(pub, DB, PubTypes, Languages);
            Publications.WritePeoplePublicationsToDB(DB, Tobian, pub);
            ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" });

            pub          = new Publication();
            Authors      = new String[] { "BUNN P", "TOBIAN L" };
            pub.Year     = 1996;
            pub.Journal  = "Xenotransplantation";
            pub.Authors  = Authors;
            pub.PMID     = 12345678;
            pub.Title    = "Fake article #2";
            pub.Language = "eng";
            pub.PubType  = "Journal Article";
            Publications.WriteToDB(pub, DB, PubTypes, Languages);
            Publications.WritePeoplePublicationsToDB(DB, Tobian, pub);
            ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" });

            pub          = new Publication();
            Authors      = new String[] { "TOBIAN L", "BUNN P" };
            pub.Year     = 1996;
            pub.Journal  = "Fake Journal";
            pub.Authors  = Authors;
            pub.PMID     = 98765432;
            pub.Title    = "Fake article #3";
            pub.Language = "eng";
            pub.PubType  = "Journal Article";
            Publications.WriteToDB(pub, DB, PubTypes, Languages);
            Publications.WritePeoplePublicationsToDB(DB, Tobian, pub);
            ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" });

            pub          = new Publication();
            Authors      = new String[] { "TOBIAN L", "BUNN P", "SCHMOE J" };
            pub.Year     = 2001;
            pub.Journal  = "Nature";
            pub.Authors  = Authors;
            pub.PMID     = 55555555;
            pub.Title    = "Fake article #4";
            pub.Language = "eng";
            pub.PubType  = "Journal Article";
            Publications.WriteToDB(pub, DB, PubTypes, Languages);
            Publications.WritePeoplePublicationsToDB(DB, Tobian, pub);
            ColleagueFinder.WriteColleaguePublicationsToDB(DB, Bunn, pub, PubTypes, new string[] { "eng" });
        }
Ejemplo n.º 28
0
        private Publication CreateTestPublication()
        {
            string MedlineData = @"PMID- 15904469
OWN - NLM
STAT- MEDLINE
DA  - 20050520
DCOM- 20050728
PUBM- Print
IS  - 1347-9032
VI  - 96
IP  - 5
DP  - 2005 May
TI  - Charcoal cigarette filters and lung cancer risk in Aichi Prefecture,
      Japan.
PG  - 283-7
AB  - The lung cancer mortality rate has been lower in Japan than in the United
      States for several decades. We hypothesized that this difference is due to
      the Japanese preference for cigarettes with charcoal-containing filters,
      which efficiently absorb selected gas phase components of mainstream smoke
      including the carcinogen 4-(methylnitrosamino)-1-(3-pyridyl)-1-butanone.
      We analyzed a subset of smokers (396 cases and 545 controls) from a
      case-control study of lung cancer conducted in Aichi Prefecture, Japan.
      The risk associated with charcoal filters (73% of all subjects) was
      evaluated after adjusting for age, sex, education and smoking dose. The
      odds ratio (OR) associated with charcoal compared with 'plain' cigarette
      filters was 1.2 (95% confidence intervals [CI] 0.9, 1.6). The
      histologic-specific risks were similar (e.g. OR = 1.3, 95% CI 0.9, 2.1 for
      adenocarcinoma). The OR was 1.7 (95% CI 1.1, 2.9) in smokers who switched
      from 'plain' to charcoal brands. The mean daily number of cigarettes
      smoked in subjects who switched from 'plain' to charcoal brands was 22.5
      and 23.0, respectively. The findings from this study did not indicate that
      charcoal filters were associated with an attenuated risk of lung cancer.
      As the detection of a modest benefit or risk (e.g. 10-20%) that can have
      significant public health impact requires large samples, the findings
      should be confirmed or refuted in larger studies.
AD  - Department of Health Evaluation Sciences, Penn State Cancer Institute,
      Division of Population Sciences, Penn State College of Medicine, Hershey,
      PA 17033, USA.
FAU - Muscat, Joshua E
AU  - Muscat JE
FAU - Takezaki, Toshiro
AU  - Takezaki T
FAU - Tajima, Kazuo
AU  - Tajima K
FAU - Stellman, Steven D
AU  - Stellman SD
LA  - eng
GR  - CA-17613/CA/NCI
GR  - CA-68387/CA/NCI
PT  - Clinical Trial
PT  - Journal Article
PL  - England
TA  - Cancer Sci
JID - 101168776
RN  - 16291-96-6 (Charcoal)
SB  - IM
MH  - Adult
MH  - Aged
MH  - Aged, 80 and over
MH  - Case-Control Studies
MH  - Charcoal/*adverse effects
MH  - Female
MH  - Filtration/*utilization
MH  - Humans
MH  - Japan
MH  - Lung Neoplasms/*etiology/pathology
MH  - Male
MH  - Middle Aged
MH  - Research Support, N.I.H., Extramural
MH  - Research Support, U.S. Gov't, Non-P.H.S.
MH  - Research Support, U.S. Gov't, P.H.S.
MH  - Risk Factors
MH  - Smoking/*adverse effects
EDAT- 2005/05/21 09:00
MHDA- 2005/07/29 09:00
AID - CAS045 [pii]
AID - 10.1111/j.1349-7006.2005.00045.x [doi]
PST - ppublish
SO  - Cancer Sci 2005 May;96(5):283-7.";

            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );

            Publications Reader = new Publications(MedlineData, ptc);

            Assert.IsTrue(Reader.PublicationList.Length == 1);
            return(Reader.PublicationList[0]);
        }
Ejemplo n.º 29
0
        public void TestColleaguesSetUp()
        {
            // Create the AAMC roster object
            roster = new Roster(AppDomain.CurrentDomain.BaseDirectory + "\\Test Data\\TestRoster\\testroster.csv");


            // Stuff for GetPublications()

            // Make an anonymous callback function that keeps track of the callback data
            Harvester.GetPublicationsStatus StatusCallback = delegate(int number, int total, int averageTime)
            {
                //
            };
            // Make an anonymous callback function to do nothing for GetPublicationsMessage
            Harvester.GetPublicationsMessage MessageCallback = delegate(string Message, bool StatusBarOnly)
            {
                //
            };
            // Make an anonymous callback function to return false for CheckForInterrupt
            Harvester.CheckForInterrupt InterruptCallback = delegate()
            {
                return(false);
            };
            double AverageMilliseconds;



            // Read the people file
            People PeopleFromFile = new People(
                AppDomain.CurrentDomain.BaseDirectory + "\\Test Data\\TestColleagues",
                "PeopleFile.xls");

            // Drop all tables from the test database
            DB = new Database("Colleague Generator Unit Test");
            foreach (string Table in new string[]
            {
                "colleaguepublications", "colleagues", "meshheadings",
                "people", "peoplepublications", "publicationauthors",
                "publicationgrants", "publicationmeshheadings", "publications",
                "pubtypecategories", "starcolleagues"
            }
                     )
            {
                DB.ExecuteNonQuery("DROP TABLE IF EXISTS " + Table + ";");
            }

            // Create the test database
            harvester = new Harvester(DB);
            harvester.CreateTables();
            ColleagueFinder.CreateTables(DB);

            // Populate it using the Mock NCBI object
            ncbi     = new MockNCBI("Medline");
            PubTypes = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Test Data\\TestColleagues",
                "PublicationTypes.csv"
                );

            // Write each person and his publications to the database
            foreach (Person person in PeopleFromFile.PersonList)
            {
                person.WriteToDB(DB);
                harvester.GetPublications(ncbi, PubTypes, person, StatusCallback, MessageCallback, InterruptCallback, out AverageMilliseconds);
            }
        }
Ejemplo n.º 30
0
        public void TestTwoPeopleWithSameNames()
        {
            Database DB = new Database("Publication Harvester Unit Test");

            // Set up the database
            TestHarvester.GetPublicationsFromInput1XLS_Using_MockNCBI(false, new string[] { "eng" }, 22);


            // Add two people to the database with the same names and search criteria
            // (where the search should make MockNCBI use OtherPeople.dat)
            string[] names = new string[2];
            names[0] = "Guy JF";
            names[1] = "Guy J";
            Person Joe = new Person("A1234567", "JOE", "FIRST", "GUY",
                                    false, names, "Special query for OtherPeople.dat");

            Joe.WriteToDB(DB);

            Person Jane = new Person("Z7654321", "JANE", "FIFTH", "GUY",
                                     false, names, "Special query for OtherPeople.dat");

            Jane.WriteToDB(DB);


            // Also add Jim, but give him an error so we can make sure it's cleared
            Person Jim = new Person("Q2222222", "JIM", "FOURTEENTH", "GUY",
                                    false, names, "Special query for OtherPeople.dat");

            Jim.WriteToDB(DB);
            Jim.WriteErrorToDB(DB, "This is an error message");


            PublicationTypes ptc = new PublicationTypes(
                AppDomain.CurrentDomain.BaseDirectory + "\\Unit Tests\\TestPublicationTypes",
                "PublicationTypes.csv"
                );


            // Make an anonymous callback function that keeps track of the callback data
            int Callbacks = 0; // this will count all of the publications

            Harvester.GetPublicationsStatus StatusCallback = delegate(int number, int total, int averageTime)
            {
                Callbacks++;
            };

            // Make an anonymous callback function to do nothing for GetPublicationsMessage
            int MessageCallbacks = 0;

            Harvester.GetPublicationsMessage MessageCallback = delegate(string Message, bool StatusBarOnly)
            {
                // Only increment MessageCallbacks if the message contains Joe's Setnb
                // and the word "same"
                if ((Message.Contains("A1234567") || (Message.Contains("Q2222222")) &&
                     Message.Contains("same")))
                {
                    MessageCallbacks++;
                }
            };

            // Make an anonymous callback function to return false for CheckForInterrupt
            Harvester.CheckForInterrupt InterruptCallback = delegate()
            {
                return(false);
            };

            // More stuff for the harvester
            Harvester harvester = new Harvester(DB);
            MockNCBI  mockNCBI  = new MockNCBI("medline");
            double    AverageMilliseconds;


            // Harvest the people
            harvester.GetPublications(mockNCBI, ptc, Jane, StatusCallback, MessageCallback, InterruptCallback, out AverageMilliseconds);

            // Make sure the harvester got Jane's publications
            DataTable Results = DB.ExecuteQuery("SELECT PMID FROM PeoplePublications WHERE Setnb = 'Z7654321'");

            Assert.AreEqual(Results.Rows.Count, 3);
            foreach (DataRow Row in Results.Rows)
            {
                Assert.IsTrue(
                    (Row["PMID"].ToString() == "2417121") ||
                    (Row["PMID"].ToString() == "12679283") ||
                    (Row["PMID"].ToString() == "14653276"));
            }
            ArrayList Parameters = new ArrayList();

            Parameters.Add(Database.Parameter(Jane.Setnb));
            Results = DB.ExecuteQuery("SELECT Harvested, Error, ErrorMessage FROM People WHERE Setnb = ?", Parameters);
            Assert.AreEqual(Results.Rows[0]["Harvested"], true);
            Assert.AreEqual(Results.Rows[0]["Error"], DBNull.Value);
            Assert.AreEqual(Results.Rows[0]["ErrorMessage"].ToString(), "");


            // It should also get Joe's publications. It should call MessageCallback()
            // twice to let us know Joe'and Jim's s publications were found, and it
            // should add the appropriate rows to PeoplePublications.
            Assert.AreEqual(MessageCallbacks, 2);
            Results = DB.ExecuteQuery("SELECT PMID FROM PeoplePublications WHERE Setnb = 'A1234567'");
            Assert.AreEqual(Results.Rows.Count, 3);
            foreach (DataRow Row in Results.Rows)
            {
                Assert.IsTrue(
                    (Row["PMID"].ToString() == "2417121") ||
                    (Row["PMID"].ToString() == "12679283") ||
                    (Row["PMID"].ToString() == "14653276"));
            }
            Parameters = new ArrayList();
            Parameters.Add(Database.Parameter(Joe.Setnb));
            Results = DB.ExecuteQuery("SELECT " + Database.PEOPLE_COLUMNS + " FROM People WHERE Setnb = ?", Parameters);
            bool boolValue; // needed for GetBoolValue workaround for bit field bug in MySQL

            Assert.IsTrue(Database.GetBoolValue(Results.Rows[0]["Harvested"], out boolValue));
            Assert.IsTrue(boolValue);
            Assert.IsTrue(Database.GetBoolValue(Results.Rows[0]["Error"], out boolValue));
            Assert.IsFalse(boolValue);
            Assert.AreEqual(Results.Rows[0]["Error"], DBNull.Value);
            Assert.AreEqual(Results.Rows[0]["ErrorMessage"].ToString(), "");



            // It should also get Jim's publications -- and it should also clear his error.
            Assert.AreEqual(MessageCallbacks, 2);
            Results = DB.ExecuteQuery("SELECT PMID FROM PeoplePublications WHERE Setnb = 'A1234567'");
            Assert.AreEqual(Results.Rows.Count, 3);
            foreach (DataRow Row in Results.Rows)
            {
                Assert.IsTrue(
                    (Row["PMID"].ToString() == "2417121") ||
                    (Row["PMID"].ToString() == "12679283") ||
                    (Row["PMID"].ToString() == "14653276"));
            }
            Parameters = new ArrayList();
            Parameters.Add(Database.Parameter(Jim.Setnb));
            Results = DB.ExecuteQuery("SELECT " + Database.PEOPLE_COLUMNS + "FROM People WHERE Setnb = ?", Parameters);

            Assert.IsTrue(Database.GetBoolValue(Results.Rows[0]["Harvested"], out boolValue));
            Assert.AreEqual(boolValue, true);
            Assert.AreEqual(Results.Rows[0]["Error"], DBNull.Value);
            Assert.AreEqual(Results.Rows[0]["ErrorMessage"].ToString(), "");
        }