Search in sources :

Example 6 with Publication

use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.

the class EuropePMCDeserializer method getPublicatonInfo.

public Publication getPublicatonInfo(JsonNode info) {
    Publication publication = new Publication();
    JsonNode root = info.get("resultList").get("result").get(0);
    System.out.println("Publication");
    publication.setPubmedId(root.get("pmid").asText());
    // publication.setPublicationDate(root.get("firstPublicationDate").asText());
    publication.setPublication(root.get("journalInfo").get("journal").get("medlineAbbreviation").asText());
    publication.setTitle(root.get("title").asText());
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    /**
     * Priority to eletronicDate. *
     */
    String datePublication = "";
    if (root.has("electronicPublicationDate")) {
        datePublication = root.get("electronicPublicationDate").asText();
    } else {
        if (root.get("journalInfo").has("printPublicationDate")) {
            datePublication = root.get("journalInfo").get("printPublicationDate").asText();
        }
    }
    if (datePublication.contains("/")) {
        datePublication = datePublication.replace("/", "-");
    }
    java.util.Date studyDate = null;
    try {
        studyDate = format.parse(datePublication);
    } catch (ParseException e1) {
        e1.printStackTrace();
    }
    publication.setPublicationDate(new Date(studyDate.getTime()));
    return publication;
}
Also used : Publication(uk.ac.ebi.spot.goci.model.Publication) JsonNode(com.fasterxml.jackson.databind.JsonNode) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.sql.Date)

Example 7 with Publication

use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.

the class CurationSystemEmailToCurator method createBody.

public void createBody(Study study, String status) {
    // Set up some of the values used in mail body
    Publication publication = study.getPublicationId();
    String studyTitle = publication.getTitle();
    String pubmedLink = "http://europepmc.org/abstract/MED/" + publication.getPubmedId();
    String currentCurator = study.getHousekeeping().getCurator().getLastName();
    // These could be null so catch this case
    String studyTrait = null;
    if (study.getDiseaseTrait() != null && !study.getDiseaseTrait().getTrait().isEmpty()) {
        studyTrait = study.getDiseaseTrait().getTrait();
    }
    StringBuilder notes = new StringBuilder();
    Collection<StudyNote> studyNotes = study.getNotes();
    if (!studyNotes.isEmpty()) {
        studyNotes.forEach(studyNote -> {
            notes.append(studyNote.toStringForEamil()).append("\n");
            notes.append("-------------------------------------------------------------\n\n");
        });
    }
    // Format dates
    Date studyDate = publication.getPublicationDate();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
    String bodyStudyDate = dateFormat.format(studyDate);
    Date publishDate = study.getHousekeeping().getCatalogPublishDate();
    String bodyPublishDate = null;
    if (publishDate != null) {
        bodyPublishDate = dateFormat.format(publishDate);
    }
    String editStudyLink = getLink() + "studies/" + study.getId();
    this.setSubject(publication.getFirstAuthor().getFullnameShort(50) + " - " + status);
    this.setBody("The GWAS paper by " + publication.getFirstAuthor().getFullname() + " with study date " + bodyStudyDate + " now has status " + status + "\n" + "Title: " + studyTitle + "\n" + "Trait: " + studyTrait + "\n" + "Pubmed link: " + pubmedLink + "\n" + "Edit link: " + editStudyLink + "\n" + "Current curator: " + currentCurator + "\n" + "Publish Date: " + bodyPublishDate + "\n" + "Notes: \n" + notes + "\n\n");
}
Also used : Publication(uk.ac.ebi.spot.goci.model.Publication) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 8 with Publication

use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.

the class PussycatGOCIController method setDateFilter.

private Filter setDateFilter(String dateMin, String dateMax) {
    Filter dateFilter;
    DateFormat df_input = new SimpleDateFormat("yyyy-MM-dd");
    Date to, from;
    try {
        if (dateMax != null) {
            int endYearVar = Integer.parseInt(dateMax.split("-")[0]);
            int endMonthVar = Integer.parseInt(dateMax.split("-")[1]);
            String end_month, end_year;
            // API call provides date for "up to and including the end of" - must increment month for query
            if (endMonthVar == 12) {
                end_month = "01";
                endYearVar++;
                end_year = Integer.toString(endYearVar);
            } else {
                endMonthVar++;
                if (endMonthVar > 9) {
                    end_month = Integer.toString(endMonthVar);
                } else {
                    end_month = "0".concat(Integer.toString(endMonthVar));
                }
                end_year = Integer.toString(endYearVar);
            }
            to = df_input.parse(end_year + "-" + end_month + "-01");
        } else {
            // change to use today's date
            to = df_input.parse(df_input.format(new Date()));
        }
        if (dateMin != null) {
            from = df_input.parse(dateMin + "-01");
        } else {
            from = df_input.parse("2005-01-01");
        }
        Calendar fromValue = Calendar.getInstance();
        fromValue.setTime(from);
        Calendar toValue = Calendar.getInstance();
        toValue.setTime(to);
        // Study study = template(Study.class);
        // dateFilter = refine(study).on(study.getPublicationId().getPublicationDate()).hasRange(fromValue, toValue);
        Publication publication = template(Publication.class);
        dateFilter = refine(publication).on(publication.getPublicationDate()).hasRange(fromValue, toValue);
    } catch (ParseException e) {
        getLog().error("Bad date in URL for date range '" + dateMin + "' to '" + dateMax, e);
        throw new RuntimeException("Bad date in URL for date range '" + dateMin + "' to '" + dateMax, e);
    }
    return dateFilter;
}
Also used : Filter(uk.ac.ebi.spot.goci.pussycat.lang.Filter) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Calendar(java.util.Calendar) Publication(uk.ac.ebi.spot.goci.model.Publication) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 9 with Publication

use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.

the class DataDeletionService method deleteStudy.

private void deleteStudy(Study study) {
    System.out.println("Removing study \t" + study.getPublicationId().getFirstAuthor().getFullname() + "\t (ID:" + study.getId() + ") with \t" + study.getAssociations().size() + "\t association and \t" + study.getAncestries().size() + "\t ancestries");
    getLog().debug("Removing study \t" + study.getPublicationId().getFirstAuthor().getFullname() + "\t (ID:" + study.getId() + ") with \t" + study.getAssociations().size() + "\t association and \t" + study.getAncestries().size() + "\t ancestries");
    // THOR - Don't delete the publication and Author - OR check if there is just a publication.
    Long publicationId = study.getPublicationId().getId();
    study.setPublicationId(null);
    studyService.setPublicationIdNull(study.getId());
    Collection<Association> associations = study.getAssociations();
    associations.forEach(this::deleteAssociation);
    Collection<Ancestry> ancestries = ancestryRepository.findByStudyId(study.getId());
    for (Ancestry ancestry : ancestries) {
        ancestryRepository.delete(ancestry);
    }
    // WeeklyTracking, CuratorTracking and Note. Please use this method!
    // Shared with === DataDeletionService ===
    studyService.deleteRelatedInfoByStudy(study);
    // Delete study
    studyService.deleteByStudyId(study.getId());
    // THOR - delete the publication if there are no studies related
    Publication publication = publicationService.deepFindPublicationbyId(publicationId);
    if (publication.getStudies().size() == 0) {
        publicationAuthorsService.deleteByPublication(publication);
        Boolean delete = publicationService.deletePublication(publication);
    }
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) Publication(uk.ac.ebi.spot.goci.model.Publication)

Example 10 with Publication

use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.

the class PublicationOperationsService method importSinglePublication.

public Publication importSinglePublication(String pubmedId, Boolean newImport) throws PubmedLookupException {
    Publication addedPublication = null;
    try {
        EuropePMCData europePMCResult = europepmcPubMedSearchService.createStudyByPubmed(pubmedId);
        addedPublication = addPublication(pubmedId, europePMCResult, newImport);
    } catch (Exception exception) {
        throw new PubmedLookupException(exception.getCause().getMessage());
    }
    return addedPublication;
}
Also used : PubmedLookupException(uk.ac.ebi.spot.goci.service.exception.PubmedLookupException) Publication(uk.ac.ebi.spot.goci.model.Publication) EuropePMCData(uk.ac.ebi.spot.goci.utils.EuropePMCData) PubmedLookupException(uk.ac.ebi.spot.goci.service.exception.PubmedLookupException) NoStudyDirectoryException(uk.ac.ebi.spot.goci.curation.exception.NoStudyDirectoryException)

Aggregations

Publication (uk.ac.ebi.spot.goci.model.Publication)11 SimpleDateFormat (java.text.SimpleDateFormat)4 ParseException (java.text.ParseException)3 Date (java.util.Date)3 NoStudyDirectoryException (uk.ac.ebi.spot.goci.curation.exception.NoStudyDirectoryException)3 PubmedLookupException (uk.ac.ebi.spot.goci.service.exception.PubmedLookupException)3 DateFormat (java.text.DateFormat)2 Association (uk.ac.ebi.spot.goci.model.Association)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Date (java.sql.Date)1 Calendar (java.util.Calendar)1 Transactional (javax.transaction.Transactional)1 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1 Ancestry (uk.ac.ebi.spot.goci.model.Ancestry)1 Author (uk.ac.ebi.spot.goci.model.Author)1 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)1 Study (uk.ac.ebi.spot.goci.model.Study)1 StudyNote (uk.ac.ebi.spot.goci.model.StudyNote)1 Filter (uk.ac.ebi.spot.goci.pussycat.lang.Filter)1