Search in sources :

Example 11 with Chromosome

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

the class BlatResultParser method parseOneLine.

@Override
public BlatResult parseOneLine(String line) {
    if (StringUtils.isBlank(line))
        return null;
    try {
        // check if it is a header line.
        if (line.startsWith("psLayout") || line.startsWith("match") || line.startsWith("    ") || line.startsWith("-----------------------")) {
            return null;
        }
        String[] f = line.split("\t");
        if (f.length == 0)
            return null;
        if (f.length != BlatResultParser.NUM_BLAT_FIELDS)
            throw new IllegalArgumentException(f.length + " fields in line, expected " + BlatResultParser.NUM_BLAT_FIELDS + " (starts with " + line.substring(0, Math.max(line.length(), 25)));
        BlatResult result = BlatResult.Factory.newInstance();
        result.setQuerySequence(BioSequence.Factory.newInstance());
        Long queryLength = Long.parseLong(f[BlatResultParser.QSIZE_FIELD]);
        result.getQuerySequence().setLength(queryLength);
        result.setMatches(Integer.parseInt(f[BlatResultParser.MATCHES_FIELD]));
        result.setMismatches(Integer.parseInt(f[BlatResultParser.MISMATCHES_FIELD]));
        result.setRepMatches(Integer.parseInt(f[BlatResultParser.REPMATCHES_FIELD]));
        result.setNs(Integer.parseInt(f[BlatResultParser.NS_FIELD]));
        result.setQueryGapCount(Integer.parseInt(f[BlatResultParser.QGAPCOUNT_FIELD]));
        result.setQueryGapBases(Integer.parseInt(f[BlatResultParser.QGAPBASES_FIELD]));
        result.setTargetGapBases(Integer.parseInt(f[BlatResultParser.TGAPBASES_FIELD]));
        result.setTargetGapCount(Integer.parseInt(f[BlatResultParser.TGAPCOUNT_FIELD]));
        result.setStrand(f[BlatResultParser.STRAND_FIELD]);
        result.setQueryStart(Integer.parseInt(f[BlatResultParser.QSTART_FIELD]));
        result.setQueryEnd(Integer.parseInt(f[BlatResultParser.QEND_FIELD]));
        result.setTargetStart(Long.parseLong(f[BlatResultParser.TSTART_FIELD]));
        result.setTargetEnd(Long.parseLong(f[BlatResultParser.TEND_FIELD]));
        result.setBlockCount(Integer.parseInt(f[BlatResultParser.BLOCKCOUNT_FIELD]));
        result.setBlockSizes(f[BlatResultParser.BLOCKSIZES_FIELD]);
        result.setQueryStarts(f[BlatResultParser.QSTARTS_FIELD]);
        result.setTargetStarts(f[BlatResultParser.TSTARTS_FIELD]);
        String queryName = f[BlatResultParser.QNAME_FIELD];
        queryName = BlatResultParser.cleanUpQueryName(queryName);
        assert StringUtils.isNotBlank(queryName);
        result.getQuerySequence().setName(queryName);
        String chrom = f[BlatResultParser.TNAME_FIELD];
        if (chrom.startsWith("chr")) {
            chrom = chrom.substring(chrom.indexOf("chr") + 3);
            if (chrom.endsWith(".fa")) {
                chrom = chrom.substring(0, chrom.indexOf(".fa"));
            }
        }
        if (scoreThreshold > 0.0 && result.score() < scoreThreshold) {
            numSkipped++;
            return null;
        }
        result.setTargetChromosome(new Chromosome(chrom, null, BioSequence.Factory.newInstance(), taxon));
        result.getTargetChromosome().getSequence().setName(chrom);
        result.getTargetChromosome().getSequence().setLength(Long.parseLong(f[BlatResultParser.TSIZE_FIELD]));
        result.getTargetChromosome().getSequence().setTaxon(taxon);
        if (searchedDatabase != null) {
            result.setSearchedDatabase(searchedDatabase);
        }
        result.setTargetAlignedRegion(this.makePhysicalLocation(result));
        return result;
    } catch (NumberFormatException e) {
        log.error("Invalid number format", e);
        return null;
    } catch (IllegalArgumentException e) {
        throw new RuntimeException(e);
    }
}
Also used : Chromosome(ubic.gemma.model.genome.Chromosome) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult)

Example 12 with Chromosome

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

the class NcbiGeneConverter method getChromosomeDetails.

private void getChromosomeDetails(NCBIGene2Accession acc, Gene gene) {
    Chromosome chrom = gene.getPhysicalLocation().getChromosome();
    BioSequence chromSeq = BioSequence.Factory.newInstance();
    chromSeq.setName(acc.getGenomicNucleotideAccession());
    chromSeq.setType(SequenceType.WHOLE_CHROMOSOME);
    chromSeq.setTaxon(gene.getTaxon());
    DatabaseEntry dbe = DatabaseEntry.Factory.newInstance();
    dbe.setExternalDatabase(NcbiGeneConverter.genBank);
    dbe.setAccession(acc.getGenomicNucleotideAccession());
    dbe.setAccessionVersion(acc.getGenomicNucleotideAccessionVersion());
    chromSeq.setSequenceDatabaseEntry(dbe);
    try {
        FieldUtils.writeField(chrom, "sequence", chromSeq, true);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) Chromosome(ubic.gemma.model.genome.Chromosome) DatabaseEntry(ubic.gemma.model.common.description.DatabaseEntry)

Example 13 with Chromosome

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

the class GeneCoreServiceTest method testLoadGeneDetails.

@Test
public void testLoadGeneDetails() {
    Gene gene = Gene.Factory.newInstance();
    Integer id = Integer.parseInt(RandomStringUtils.randomNumeric(5));
    gene.setNcbiGeneId(id);
    gene.setName("test_genedao");
    gene.setOfficialName("test_genedao");
    gene.setOfficialSymbol("test_genedao");
    Taxon human = taxonService.findByCommonName("human");
    gene.setTaxon(human);
    PhysicalLocation pl1 = PhysicalLocation.Factory.newInstance();
    Chromosome chromosome = new Chromosome("X", null, this.getTestPersistentBioSequence(), human);
    chromosome = (Chromosome) persisterHelper.persist(chromosome);
    pl1.setChromosome(chromosome);
    pl1.setNucleotide(10000010L);
    pl1.setNucleotideLength(1001);
    pl1.setStrand("-");
    gene.setPhysicalLocation(pl1);
    gene = geneDao.create(gene);
    Long idWeWant = gene.getId();
    gene.setId(null);
    Gene g = geneDao.find(gene);
    assertNotNull(g);
    assertEquals(idWeWant, g.getId());
    GeneValueObject gvo = geneCoreService.loadGeneDetails(idWeWant);
    assertEquals(gvo.getName(), g.getName());
    geneDao.remove(g);
}
Also used : Gene(ubic.gemma.model.genome.Gene) Taxon(ubic.gemma.model.genome.Taxon) Chromosome(ubic.gemma.model.genome.Chromosome) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation) Test(org.junit.Test) BaseSpringContextTest(ubic.gemma.core.testing.BaseSpringContextTest)

Example 14 with Chromosome

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

the class PersistentDummyObjectHelper method getTestPersistentBlatResult.

public BlatResult getTestPersistentBlatResult(BioSequence querySequence, Taxon taxon) {
    BlatResult br = BlatResult.Factory.newInstance();
    if (taxon == null) {
        taxon = this.getTestPersistentTaxon();
    }
    Chromosome chromosome = new Chromosome("XXX", null, this.getTestPersistentBioSequence(taxon), taxon);
    assert chromosome.getSequence() != null;
    chromosome = (Chromosome) persisterHelper.persist(chromosome);
    assert chromosome != null;
    assert chromosome.getSequence() != null;
    br.setTargetChromosome(chromosome);
    assert br.getTargetChromosome().getSequence() != null;
    br.setQuerySequence(querySequence);
    br.setTargetStart(1L);
    br.setTargetEnd(1000L);
    PhysicalLocation targetAlignedRegion = PhysicalLocation.Factory.newInstance();
    targetAlignedRegion.setChromosome(br.getTargetChromosome());
    targetAlignedRegion.setNucleotide(10000010L);
    targetAlignedRegion.setNucleotideLength(1001);
    targetAlignedRegion.setStrand("-");
    return (BlatResult) persisterHelper.persist(br);
}
Also used : Chromosome(ubic.gemma.model.genome.Chromosome) BlatResult(ubic.gemma.model.genome.sequenceAnalysis.BlatResult) PhysicalLocation(ubic.gemma.model.genome.PhysicalLocation)

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