Exemplo n.º 1
0
def db_dump():
    """Generates the release file containing all binding sites in CollecTF."""
    curation_site_instances = models.Curation_SiteInstance.objects.all()
    reports = motif_report.build_motif_reports(curation_site_instances)
    meta_sites = [meta_site
                  for report in reports
                  for meta_site in report.meta_sites]
    tsv_raw = export.export_tsv(meta_sites)
    export_file = os.path.join(
        settings.STATICFILES_DIRS[0], 'collectf_export.tsv')
    with open(export_file, 'w') as f:
        f.write(tsv_raw)
Exemplo n.º 2
0
def db_dump():
    """Generates the release file containing all binding sites in CollecTF."""
    curation_site_instances = models.Curation_SiteInstance.objects.all()
    reports = motif_report.build_motif_reports(curation_site_instances)
    meta_sites = [
        meta_site for report in reports for meta_site in report.meta_sites
    ]
    tsv_raw = export.export_tsv(meta_sites)
    export_file = os.path.join(settings.STATICFILES_DIRS[0],
                               'collectf_export.tsv')
    with open(export_file, 'w') as f:
        f.write(tsv_raw)
Exemplo n.º 3
0
def generate_uniprot_dbxref():
    export_file = os.path.join(settings.STATICFILES_DIRS[0], "uniprot_dbxref.txt")
    with open(export_file, "w") as f:
        for TF_instance in models.TFInstance.objects.all():
            print TF_instance
            reports = motif_report.build_motif_reports(
                models.Curation_SiteInstance.objects.filter(curation__TF_instances=TF_instance)
            )
            if reports:
                f.write(
                    "\t".join([TF_instance.uniprot_accession, dbxref.to_uniprot_dbxref(TF_instance.TF_instance_id)])
                )
                f.write("\n")
Exemplo n.º 4
0
def all_alignments():
    """Generates aligned binding moitfs."""
    curation_site_instances = models.Curation_SiteInstance.objects.all()
    reports = motif_report.build_motif_reports(curation_site_instances)
    zip_file_name = os.path.join(settings.STATICFILES_DIRS[0],
                                 'collectf_alignments.zip')
    with ZipFile(zip_file_name, 'w') as zip:
        for report in reports:
            if len(report.aligned_sites) >= 8:
                tf = report.TF_name
                species = report.short_species_name.replace('.', '_')
                print tf, species
                filename = '%s_%s.txt' % (tf, species)
                zip.writestr(filename, '\n'.join(report.aligned_sites))
Exemplo n.º 5
0
def generate_uniprot_dbxref():
    export_file = os.path.join(settings.STATICFILES_DIRS[0],
                               'uniprot_dbxref.txt')
    with open(export_file, 'w') as f:
        for TF_instance in models.TFInstance.objects.all():
            print TF_instance
            reports = motif_report.build_motif_reports(
                models.Curation_SiteInstance.objects.filter(
                    curation__TF_instances=TF_instance))
            if reports:
                f.write('\t'.join(
                    [TF_instance.uniprot_accession,
                     dbxref.to_uniprot_dbxref(TF_instance.TF_instance_id)]))
                f.write('\n')
Exemplo n.º 6
0
def all_alignments():
    """Generates aligned binding moitfs."""
    curation_site_instances = models.Curation_SiteInstance.objects.all()
    reports = motif_report.build_motif_reports(curation_site_instances)
    zip_file_name = os.path.join(settings.STATICFILES_DIRS[0],
                                 'collectf_alignments.zip')
    with ZipFile(zip_file_name, 'w') as zip:
        for report in reports:
            if len(report.aligned_sites) >= 8:
                tf = report.TF_name
                species = report.short_species_name.replace('.', '_')
                print tf, species
                filename = '%s_%s.txt' % (tf, species)
                zip.writestr(filename, '\n'.join(report.aligned_sites))
Exemplo n.º 7
0
def generate_motif_file():
    """Generates motif file containing all motifs for each TF-instance."""
    export_file = os.path.join(settings.STATICFILES_DIRS[0],
                               'collectf_meme.cm')
    with open(export_file, 'w') as f:
        for TF_instance in models.TFInstance.objects.all():
            print TF_instance
            reports = motif_report.build_motif_reports(
                models.Curation_SiteInstance.objects.filter(
                    curation__TF_instances=TF_instance))
            if reports:
                sites = reports[0].aligned_sites
                if len(sites) < 10:
                    continue
                motif = build_motif(sites)
                f.write('>%s %s_%s\n' % (
                    dbxref.to_uniprot_dbxref(TF_instance.TF_instance_id),
                    reports[0].TF_name,
                    reports[0].short_species_name))
                f.write('%s\n' % '\t'.join(map(str, motif.counts['A'])))
                f.write('%s\n' % '\t'.join(map(str, motif.counts['C'])))
                f.write('%s\n' % '\t'.join(map(str, motif.counts['G'])))
                f.write('%s\n' % '\t'.join(map(str, motif.counts['T'])))