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;
}
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");
}
}
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;
}
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;
}
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;
}
Aggregations