Search in sources :

Example 6 with Chromosome

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

the class NcbiGeneConverter method convert.

public Gene convert(NCBIGeneInfo info) {
    Gene gene = Gene.Factory.newInstance();
    gene.setNcbiGeneId(Integer.parseInt(info.getGeneId()));
    gene.setName(info.getDefaultSymbol());
    gene.setOfficialSymbol(info.getDefaultSymbol());
    gene.setOfficialName(info.getDescription());
    gene.setEnsemblId(info.getEnsemblId());
    /*
         * NOTE we allow multiple discontinued or previous ids, separated by commas. This is a hack to account for cases
         * uncovered recently...can be minimized by running this regularly.
         */
    if (info.getHistory() != null) {
        assert info.getHistory().getCurrentId() == null || info.getGeneId().equals(info.getHistory().getCurrentId());
        assert info.getHistory().getPreviousIds() != null;
        if (!info.getHistory().getPreviousIds().isEmpty()) {
            String previousIds = StringUtils.join(info.getHistory().getPreviousIds(), ",");
            gene.setPreviousNcbiId(previousIds);
        }
    } else if (StringUtils.isNotBlank(info.getDiscontinuedId())) {
        if (NcbiGeneConverter.log.isDebugEnabled())
            NcbiGeneConverter.log.debug("Gene matches a gene that was discontinued: " + gene + " matches gene that had id " + info.getDiscontinuedId());
        gene.setPreviousNcbiId(info.getDiscontinuedId());
    }
    gene.setDescription("Imported from NCBI gene; Nomenclature status: " + info.getNomenclatureStatus());
    Taxon t = Taxon.Factory.newInstance();
    t.setNcbiId(info.getTaxId());
    t.setIsGenesUsable(false);
    t.setIsSpecies(true);
    gene.setTaxon(t);
    /*
         * We are going to stop maintaining this information
         */
    PhysicalLocation pl = PhysicalLocation.Factory.newInstance();
    Chromosome chrom = new Chromosome(info.getChromosome(), t);
    pl.setChromosome(chrom);
    gene.setPhysicalLocation(pl);
    Collection<GeneAlias> aliases = gene.getAliases();
    for (String alias : info.getSynonyms()) {
        GeneAlias newAlias = GeneAlias.Factory.newInstance();
        newAlias.setAlias(alias);
        aliases.add(newAlias);
    }
    for (String dbname : info.getDbXrefs().keySet()) {
        if (!dbname.equalsIgnoreCase("Ensembl"))
            continue;
        String identifier = info.getDbXrefs().get(dbname);
        DatabaseEntry crossref = DatabaseEntry.Factory.newInstance();
        crossref.setAccession(identifier);
        crossref.setExternalDatabase(NcbiGeneConverter.getEnsembl());
        gene.getAccessions().add(crossref);
    }
    return gene;
}
Also used : Gene(ubic.gemma.model.genome.Gene) GeneAlias(ubic.gemma.model.genome.gene.GeneAlias) Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome) DatabaseEntry(ubic.gemma.model.common.description.DatabaseEntry) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation)

Example 7 with Chromosome

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

the class GoldenPathQuery method convertResult.

private BlatResult convertResult(ResultSet rs) throws SQLException {
    BlatResult result = BlatResult.Factory.newInstance();
    result.setQuerySequence(BioSequence.Factory.newInstance());
    Long queryLength = rs.getLong("qSize");
    result.getQuerySequence().setLength(queryLength);
    result.setMatches(rs.getInt("matches"));
    result.setMismatches(rs.getInt("misMatches"));
    result.setRepMatches(rs.getInt("repMatches"));
    result.setNs(rs.getInt("nCount"));
    result.setQueryGapCount(rs.getInt("qNumInsert"));
    result.setQueryGapBases(rs.getInt("qBaseInsert"));
    result.setTargetGapCount(rs.getInt("tNumInsert"));
    result.setTargetGapBases(rs.getInt("tBaseInsert"));
    result.setStrand(rs.getString("strand"));
    result.setQueryStart(rs.getInt("qStart"));
    result.setQueryEnd(rs.getInt("qEnd"));
    result.setTargetStart(rs.getLong("tStart"));
    result.setTargetEnd(rs.getLong("tEnd"));
    result.setBlockCount(rs.getInt("blockCount"));
    result.setBlockSizes(SQLUtils.blobToString(rs.getBlob("blockSizes")));
    result.setQueryStarts(SQLUtils.blobToString(rs.getBlob("qStarts")));
    result.setTargetStarts(SQLUtils.blobToString(rs.getBlob("tStarts")));
    String queryName = rs.getString("qName");
    queryName = BlatResultParser.cleanUpQueryName(queryName);
    result.getQuerySequence().setName(queryName);
    String chrom = rs.getString("tName");
    if (chrom.startsWith("chr")) {
        chrom = chrom.substring(chrom.indexOf("chr") + 3);
        if (chrom.endsWith(".fa")) {
            chrom = chrom.substring(0, chrom.indexOf(".fa"));
        }
    }
    result.setTargetChromosome(new Chromosome(chrom, null, BioSequence.Factory.newInstance(), this.getTaxon()));
    result.getTargetChromosome().getSequence().setName(chrom);
    result.getTargetChromosome().getSequence().setLength(rs.getLong("tSize"));
    result.getTargetChromosome().getSequence().setTaxon(this.getTaxon());
    result.setSearchedDatabase(this.getSearchedDatabase());
    return result;
}
Also used : Chromosome(ubic.gemma.model.genome.Chromosome) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 8 with Chromosome

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

the class ChromosomeDaoImpl method findOrCreate.

@Override
public Chromosome findOrCreate(Chromosome entity) {
    String name = entity.getName();
    Taxon taxon = entity.getSequence().getTaxon();
    Collection<Chromosome> hits = this.find(name, taxon);
    if (hits == null || hits.isEmpty()) {
        Chromosome c = new Chromosome(name, taxon);
        return this.create(c);
    }
    return hits.iterator().next();
}
Also used : Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome)

Example 9 with Chromosome

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

the class MockBlat method blatQuery.

@Override
public Collection<BlatResult> blatQuery(BioSequence b) {
    Collection<BlatResult> result = new HashSet<>();
    BioSequence chromseq = PersistentDummyObjectHelper.getTestNonPersistentBioSequence(taxon);
    chromseq.setLength((long) 1e7);
    BlatResult br = BlatResult.Factory.newInstance();
    Chromosome chromosome = new Chromosome("XXX", null, chromseq, taxon);
    br.setTargetChromosome(chromosome);
    assert br.getTargetChromosome().getSequence() != null;
    long targetStart = MockBlat.RANDOM.nextInt(chromseq.getLength().intValue());
    br.setQuerySequence(b);
    br.setTargetStart(targetStart);
    br.setTargetEnd(targetStart + b.getLength());
    br.setMatches((int) (b.getLength() - 1));
    br.setMismatches(1);
    br.setRepMatches(0);
    br.setQueryGapCount(0);
    br.setQueryGapBases(0);
    br.setQueryStart(0);
    br.setQueryEnd(b.getLength().intValue());
    br.setTargetGapBases(0);
    br.setTargetGapCount(0);
    PhysicalLocation targetAlignedRegion = PhysicalLocation.Factory.newInstance();
    targetAlignedRegion.setChromosome(br.getTargetChromosome());
    targetAlignedRegion.setNucleotide(targetStart);
    targetAlignedRegion.setNucleotideLength(b.getLength().intValue());
    targetAlignedRegion.setStrand("+");
    result.add(br);
    return result;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Chromosome(ubic.gemma.model.genome.Chromosome) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation)

Example 10 with Chromosome

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

the class BlatAssociationScorerTest method createBlatResult.

private BlatResult createBlatResult(String name) {
    BlatResult blatResult = BlatResult.Factory.newInstance();
    blatResult.setRepMatches(0);
    blatResult.setMatches(49);
    blatResult.setQueryGapCount(0);
    blatResult.setTargetGapCount(2);
    blatResult.setMismatches(1);
    BioSequence sequence = BioSequence.Factory.newInstance();
    blatResult.setQuerySequence(sequence);
    blatResult.getQuerySequence().setLength(50L);
    Taxon taxon = Taxon.Factory.newInstance();
    taxon.setCommonName("human");
    Chromosome chr = new Chromosome(name, taxon);
    blatResult.setTargetChromosome(chr);
    return blatResult;
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Aggregations

Chromosome (ubic.gemma.model.genome.Chromosome)14 PhysicalLocation (ubic.gemma.model.genome.PhysicalLocation)9 Taxon (ubic.gemma.model.genome.Taxon)8 BlatResult (ubic.gemma.model.genome.sequenceAnalysis.BlatResult)5 Gene (ubic.gemma.model.genome.Gene)4 Test (org.junit.Test)3 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)3 BioSequence (ubic.gemma.model.genome.biosequence.BioSequence)3 DatabaseEntry (ubic.gemma.model.common.description.DatabaseEntry)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 GeneServiceImpl (ubic.gemma.core.genome.gene.service.GeneServiceImpl)1 BioSequence2GeneProduct (ubic.gemma.model.association.BioSequence2GeneProduct)1 GeneAlias (ubic.gemma.model.genome.gene.GeneAlias)1 GeneProduct (ubic.gemma.model.genome.gene.GeneProduct)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1 GeneDaoImpl (ubic.gemma.persistence.service.genome.GeneDaoImpl)1 GemmaApiException (ubic.gemma.web.services.rest.util.GemmaApiException)1 WellComposedErrorBody (ubic.gemma.web.services.rest.util.WellComposedErrorBody)1