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