Search in sources :

Example 36 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class PhenotypeAssociationManagerServiceImpl method makeEvidence.

@Override
@Transactional
public ValidateEvidenceValueObject makeEvidence(EvidenceValueObject<? extends PhenotypeAssociation> evidence) {
    if (evidence.getPhenotypes().isEmpty()) {
        throw new IllegalArgumentException("Cannot create an Evidence with no Phenotype");
    }
    if (evidence.getGeneNCBI() == null) {
        throw new IllegalArgumentException("Cannot create an Evidence not linked to a Gene");
    }
    StopWatch sw = new StopWatch();
    sw.start();
    PhenotypeAssociationManagerServiceImpl.log.debug("Create PhenotypeAssociation on geneNCBI: " + evidence.getGeneNCBI() + " to " + StringUtils.join(evidence.getPhenotypes(), ","));
    if (this.evidenceAlreadyInDatabase(evidence) != null) {
        ValidateEvidenceValueObject validateEvidenceValueObject = new ValidateEvidenceValueObject();
        validateEvidenceValueObject.setSameEvidenceFound(true);
        PhenotypeAssociationManagerServiceImpl.log.info("The evidence is already in the database: " + evidence.getGeneNCBI() + " to " + StringUtils.join(evidence.getPhenotypes(), ",") + ", no change will be made");
        return validateEvidenceValueObject;
    }
    if (!StringUtil.containsValidCharacter(evidence.getDescription())) {
        ValidateEvidenceValueObject validateEvidenceValueObject = new ValidateEvidenceValueObject();
        validateEvidenceValueObject.setDescriptionInvalidSymbol(true);
        return validateEvidenceValueObject;
    }
    PhenotypeAssociation phenotypeAssociation = this.phenotypeAssoManagerServiceHelper.valueObject2Entity(evidence);
    phenotypeAssociation.setLastUpdated(new Date());
    assert !phenotypeAssociation.getPhenotypes().isEmpty();
    phenotypeAssociation = this.phenoAssocService.create(phenotypeAssociation);
    /*
         * NOTE : me and Anton used this solution, if not would cause problems in other services calls,would return the
         * cached unchanged version of it, we found documentation on this, might be a better way to do it
         */
    Gene gene = phenotypeAssociation.getGene();
    gene.getPhenotypeAssociations().add(phenotypeAssociation);
    if (sw.getTime() > 100)
        PhenotypeAssociationManagerServiceImpl.log.info("The create method took : " + sw + "  " + evidence.getGeneNCBI());
    return null;
}
Also used : Gene(ubic.gemma.model.genome.Gene) StopWatch(org.apache.commons.lang3.time.StopWatch) Transactional(org.springframework.transaction.annotation.Transactional)

Example 37 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class ArrayDesignAnnotationFileCli method processGeneList.

private void processGeneList() throws IOException {
    AbstractCLI.log.info("Loading genes to annotate from " + geneFileName);
    InputStream is = new FileInputStream(geneFileName);
    try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
        String line;
        GeneService geneService = this.getBean(GeneService.class);
        TaxonService taxonService = this.getBean(TaxonService.class);
        Taxon taxon = taxonService.findByCommonName(taxonName);
        if (taxon == null) {
            throw new IllegalArgumentException("Unknown taxon: " + taxonName);
        }
        Collection<Gene> genes = new HashSet<>();
        while ((line = br.readLine()) != null) {
            if (StringUtils.isBlank(line)) {
                continue;
            }
            String[] arguments = StringUtils.split(line, '\t');
            String gene = arguments[0];
            Gene g = geneService.findByOfficialSymbol(gene, taxon);
            if (g == null) {
                AbstractCLI.log.info("Gene: " + gene + " not found.");
                continue;
            }
            genes.add(g);
        }
        AbstractCLI.log.info("File contained " + genes.size() + " potential gene symbols");
        int numProcessed = arrayDesignAnnotationService.generateAnnotationFile(new PrintWriter(System.out), genes, OutputType.SHORT);
        AbstractCLI.log.info("Processed " + numProcessed + " genes that were found");
    }
}
Also used : GeneService(ubic.gemma.core.genome.gene.service.GeneService) TaxonService(ubic.gemma.persistence.service.genome.taxon.TaxonService) Taxon(ubic.gemma.model.genome.Taxon) Gene(ubic.gemma.model.genome.Gene) HashSet(java.util.HashSet)

Example 38 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class GoldenPathSequenceAnalysis method checkRNAs.

/**
 * Recompute the exonOverlap looking at mRNAs. This lets us be a little less conservative about how we compute exon
 * overlaps.
 *
 * @param chromosome chromosome
 * @param queryStart start
 * @param queryEnd end
 * @param starts starts
 * @param sizes sizes
 * @param exonOverlap Exon overlap we're starting with. We only care to improve on this.
 * @param strand of the region
 * @param gene gene
 * @return The best overlap with any exons from an mRNA in the selected region.
 */
@SuppressWarnings("unchecked")
private int checkRNAs(String chromosome, Long queryStart, Long queryEnd, String starts, String sizes, int exonOverlap, String strand, Gene gene) {
    String key = "MRNA " + chromosome + "||" + queryStart.toString() + "||" + queryEnd.toString() + strand;
    Collection<Gene> mRNAs;
    if (cache.containsKey(key)) {
        mRNAs = (Collection<Gene>) cache.get(key);
    } else {
        mRNAs = this.findRNAs(chromosome, queryStart, queryEnd, strand);
        cache.put(key, mRNAs);
    }
    if (mRNAs.size() > 0) {
        if (GoldenPath.log.isDebugEnabled())
            GoldenPath.log.debug(mRNAs.size() + " mRNAs found at chr" + chromosome + ":" + queryStart + "-" + queryEnd + ", trying to improve overlap of  " + exonOverlap);
        int maxOverlap = exonOverlap;
        for (Gene mRNA : mRNAs) {
            if (gene != null && !gene.getOfficialSymbol().equals(this.getGeneForMessage(mRNA.getOfficialSymbol()))) {
                continue;
            }
            int overlap = SequenceManipulation.getGeneExonOverlaps(chromosome, starts, sizes, null, mRNA);
            if (GoldenPath.log.isDebugEnabled())
                GoldenPath.log.debug("overlap with " + mRNA.getNcbiGeneId() + "=" + overlap);
            if (overlap > maxOverlap) {
                if (GoldenPath.log.isDebugEnabled())
                    GoldenPath.log.debug("Best mRNA overlap=" + overlap);
                maxOverlap = overlap;
            }
        }
        exonOverlap = maxOverlap;
        if (GoldenPath.log.isDebugEnabled())
            GoldenPath.log.debug("Overlap with mRNAs is now " + exonOverlap);
    }
    return exonOverlap;
}
Also used : Gene(ubic.gemma.model.genome.Gene)

Example 39 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class GoldenPathSequenceAnalysis method checkESTs.

/**
 * Recompute the exonOverlap looking at EST evidence. This lets us be a much less conservative about how we compute
 * exon overlaps.
 *
 * @param chromosome chromosome
 * @param queryStart start
 * @param queryEnd end
 * @param starts starts
 * @param sizes sizes
 * @param exonOverlap Exon overlap we're starting with. We only care to improve on this.
 * @param strand of the region
 * @return The best overlap with any exons from an mRNA in the selected region.
 */
@SuppressWarnings("unchecked")
private int checkESTs(String chromosome, Long queryStart, Long queryEnd, String starts, String sizes, int exonOverlap, String strand) {
    String key = "EST " + chromosome + "||" + queryStart.toString() + "||" + queryEnd.toString() + strand;
    Collection<Gene> ests;
    if (cache.containsKey(key)) {
        ests = (Collection<Gene>) cache.get(key);
    } else {
        ests = this.findESTs(chromosome, queryStart, queryEnd, strand);
        cache.put(key, ests);
    }
    if (ests.size() > 0) {
        if (GoldenPath.log.isDebugEnabled())
            GoldenPath.log.debug(ests.size() + " ESTs found at chr" + chromosome + ":" + queryStart + "-" + queryEnd + ", trying to improve overlap of  " + exonOverlap);
        int maxOverlap = exonOverlap;
        for (Gene est : ests) {
            int overlap = SequenceManipulation.getGeneExonOverlaps(chromosome, starts, sizes, null, est);
            if (GoldenPath.log.isDebugEnabled())
                GoldenPath.log.debug("overlap with " + est.getNcbiGeneId() + "=" + overlap);
            if (overlap > maxOverlap) {
                if (GoldenPath.log.isDebugEnabled())
                    GoldenPath.log.debug("Best EST overlap=" + overlap);
                maxOverlap = overlap;
            }
        }
        exonOverlap = maxOverlap;
        if (GoldenPath.log.isDebugEnabled())
            GoldenPath.log.debug("Overlap with ESTs is now " + exonOverlap);
    }
    return exonOverlap;
}
Also used : Gene(ubic.gemma.model.genome.Gene)

Example 40 with Gene

use of ubic.gemma.model.genome.Gene in project Gemma by PavlidisLab.

the class BlatAssociationScorer method organizeBlatAssociationsByGene.

private static Map<Gene, Collection<BlatAssociation>> organizeBlatAssociationsByGene(Collection<BlatAssociation> blatAssociations) {
    Map<Gene, Collection<BlatAssociation>> genes = new HashMap<>();
    for (BlatAssociation blatAssociation : blatAssociations) {
        Gene gene = blatAssociation.getGeneProduct().getGene();
        if (!genes.containsKey(gene)) {
            genes.put(gene, new HashSet<BlatAssociation>());
        }
        genes.get(gene).add(blatAssociation);
    }
    return genes;
}
Also used : Gene(ubic.gemma.model.genome.Gene) HashMap(java.util.HashMap) Collection(java.util.Collection) BlatAssociation(ubic.gemma.model.genome.sequenceAnalysis.BlatAssociation)

Aggregations

Gene (ubic.gemma.model.genome.Gene)186 Taxon (ubic.gemma.model.genome.Taxon)34 CompositeSequence (ubic.gemma.model.expression.designElement.CompositeSequence)32 StopWatch (org.apache.commons.lang3.time.StopWatch)31 Test (org.junit.Test)24 HashSet (java.util.HashSet)23 GeneProduct (ubic.gemma.model.genome.gene.GeneProduct)20 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)18 Element (org.w3c.dom.Element)16 ArrayList (java.util.ArrayList)13 Transactional (org.springframework.transaction.annotation.Transactional)12 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)12 Collection (java.util.Collection)11 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)11 CharacteristicValueObject (ubic.gemma.model.genome.gene.phenotype.valueObject.CharacteristicValueObject)10 HashMap (java.util.HashMap)8 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)8 BioSequence2GeneProduct (ubic.gemma.model.association.BioSequence2GeneProduct)7 PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)7 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)7