def setUp(self, rename_func=None):
        self.tmp_files = list()

        self.ref_len_file = StringIO(TRANSCRIPT_LENGTHS)
        self.annotation_file = StringIO(TRANSCRIPT_ANNOTATION)
        self.alignment_file_1 = StringIO(READ_SET_1)
        self.alignment_file_2 = StringIO(READ_SET_2)

        self.handle = h5py.File(BytesIO(), "w")
        self.handle_2 = h5py.File(BytesIO(), "w")

        create.create_ribo(ribo=self.handle,
                           experiment_name="merzifon",
                           alignment_file=self.alignment_file_1,
                           reference_name="hg38",
                           lengths_file=self.ref_len_file,
                           annotation_file=self.annotation_file,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           length_min=2,
                           length_max=5,
                           store_coverage=False,
                           nprocess=NPROCESS,
                           tmp_file_prefix="")
        self.ref_len_file.seek(0)
        self.annotation_file.seek(0)
        self.alignment_file_1 = StringIO(READ_SET_1)

        set_metadata(self.handle, "merzifon", METADATA_EXPERIMENT_DICT)

        create.create_ribo(ribo=self.handle_2,
                           experiment_name="ankara",
                           alignment_file=self.alignment_file_2,
                           reference_name="hg38",
                           lengths_file=self.ref_len_file,
                           annotation_file=self.annotation_file,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           length_min=2,
                           length_max=5,
                           store_coverage=True,
                           nprocess=NPROCESS,
                           tmp_file_prefix="")
        self.ref_len_file.seek(0)
        self.annotation_file.seek(0)
        self.alignment_file_2 = StringIO(READ_SET_2)

        self.merged_io = BytesIO()
        self.merged_ribo = h5py.File(self.merged_io, "w")
        merge_ribos(self.merged_ribo, [self.handle, self.handle_2])
        set_metadata(self.merged_ribo, name=None, metadata=RIBO_METADATA_STR_1)
        self.merged_ribo.close()

        self.sample_ribo = Ribo(self.merged_io, alias=rename_func)
示例#2
0
    def setUp(self):
        self.tmp_files = list()

        self.ref_len_file = StringIO(TRANSCRIPT_LENGTHS)
        self.annotation_file = StringIO(TRANSCRIPT_ANNOTATION)
        self.alignment_file_1 = StringIO(READ_SET_1)
        self.alignment_file_2 = StringIO(READ_SET_2)
        self.in_ref_len_file = StringIO(INCOMPATIBLE_TRANSCRIPT_LENGTHS)
        self.in_annotation_file = StringIO(INCOMPATIBLE_TRANSCRIPT_ANNOTATION)

        self.handle = h5py.File(BytesIO(), "w")
        self.handle_2 = h5py.File(BytesIO(), "w")

        create.create_ribo(ribo=self.handle,
                           experiment_name="merzifon",
                           alignment_file=self.alignment_file_1,
                           reference_name="hg38",
                           lengths_file=self.ref_len_file,
                           annotation_file=self.annotation_file,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           length_min=2,
                           length_max=5,
                           nprocess=NPROCESS,
                           tmp_file_prefix="")
        self.ref_len_file.seek(0)
        self.annotation_file.seek(0)
        self.alignment_file_1 = StringIO(READ_SET_1)

        create.create_ribo(ribo=self.handle_2,
                           experiment_name="ankara",
                           alignment_file=self.alignment_file_2,
                           reference_name="hg38",
                           lengths_file=self.ref_len_file,
                           annotation_file=self.annotation_file,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           length_min=2,
                           length_max=5,
                           nprocess=NPROCESS,
                           tmp_file_prefix="")
        self.ref_len_file.seek(0)
        self.annotation_file.seek(0)
        self.alignment_file_2 = StringIO(READ_SET_2)

        self.merged_ribo = h5py.File(BytesIO(), "w")
        merge_ribos(self.merged_ribo, [self.handle, self.handle_2])
示例#3
0
    def setUp(self):
        self.ref_len_file = StringIO(TRANSCRIPT_LENGTHS)
        self.annotation_file = StringIO(TRANSCRIPT_ANNOTATION)
        self.alignment_file = StringIO(READ_SET_1)
        self.alignment_file_2 = StringIO(READ_SET_2)
        self.tsv_1 = StringIO(rnaseq_data.RNASEQ_tsv_1)
        self.tsv_2 = StringIO(rnaseq_data.RNASEQ_tsv_2)
        self.tsv_3 = StringIO(rnaseq_data.RNASEQ_tsv_3)

        self.handle = h5py.File(BytesIO(), "w")
        self.handle_2 = h5py.File(BytesIO(), "w")

        self.rnaseq_reads_handle = StringIO(rnaseq_data.RNASEQ_READS)
        self.rnaseq_reads_handle_2 = StringIO(rnaseq_data.RNASEQ_READS_2)

        create.create_ribo(self.handle,
                           "merzifon",
                           alignment_file=self.alignment_file,
                           reference_name="appris_human_v2",
                           length_min=2,
                           length_max=5,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           lengths_file=self.ref_len_file,
                           store_coverage=True,
                           annotation_file=self.annotation_file)

        self.ref_len_file.seek(0)
        self.annotation_file.seek(0)

        create.create_ribo(self.handle_2,
                           "adana",
                           alignment_file=self.alignment_file_2,
                           reference_name="appris_human_v2",
                           length_min=2,
                           length_max=5,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           lengths_file=self.ref_len_file,
                           store_coverage=True,
                           annotation_file=self.annotation_file)

        self.merged_ribo = h5py.File(BytesIO(), "w")
        merge_ribos(self.merged_ribo, [self.handle, self.handle_2])
示例#4
0
    def setUp(self):
        self.ref_len_file = StringIO(TRANSCRIPT_LENGTHS)
        self.annotation_file = StringIO(TRANSCRIPT_ANNOTATION)
        self.alignment_file = StringIO(READ_SET_1)
        self.handle = h5py.File(BytesIO(), "w")

        create.create_ribo(self.handle,
                           experiment_name="merzifon",
                           alignment_file=self.alignment_file,
                           metagene_radius=3,
                           length_min=2,
                           length_max=5,
                           left_span=3,
                           right_span=2,
                           reference_name="appris_human_v2",
                           lengths_file=self.ref_len_file,
                           annotation_file=self.annotation_file)
示例#5
0
    def setUp(self):

        self.len_file        = StringIO(TRANSCRIPT_LENGTHS)
        self.annotation_file = StringIO(TRANSCRIPT_ANNOTATION)
        self.alignment_file  = StringIO(READ_SET_1)

        self.handle = h5py.File(BytesIO(), "w")

        create.create_ribo(self.handle,
                experiment_name        = "merzifon",
                alignment_file      = self.alignment_file,
                reference_name      = "hg38",
                lengths_file        = self.len_file,
                annotation_file     = self.annotation_file,
                metagene_radius     = METAGENE_RADIUS,
                left_span = LEFT_SPAN, right_span = RIGHT_SPAN,
                length_min = 2, length_max = 5,
                tmp_file_prefix     = "")
示例#6
0
    def setUp(self):
        self.ref_len_file = StringIO(TRANSCRIPT_LENGTHS)
        self.annotation_file = StringIO(TRANSCRIPT_ANNOTATION)
        self.alignment_file = StringIO(READ_SET_1)

        self.handle = h5py.File(BytesIO(), "w")

        create.create_ribo(self.handle,
                           "merzifon",
                           alignment_file=self.alignment_file,
                           reference_name="appris_human_v2",
                           length_min=2,
                           length_max=5,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           lengths_file=self.ref_len_file,
                           store_coverage=True,
                           annotation_file=self.annotation_file)
    def setUp(self):
        super().setUp()
        self.file_handle_3 = BytesIO()
        self.ribo_handle_3 = h5py.File(self.file_handle_3, "w")

        create.create_ribo(ribo=self.ribo_handle_3,
                           experiment_name="adana",
                           alignment_file=self.alignment_file_1,
                           reference_name="hg38",
                           lengths_file=self.ref_len_file,
                           annotation_file=self.annotation_file,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           length_min=2,
                           length_max=5,
                           store_coverage=True,
                           nprocess=1,
                           tmp_file_prefix="")

        self.ribo_handle_3.close()
        self.adana_ribo = Ribo(self.file_handle_3)
示例#8
0
    def test_merge_incompatible_reference(self):
        handle_incompatible = h5py.File(BytesIO(), "w")
        ribo_out = h5py.File(BytesIO(), "w")

        create.create_ribo(
            ribo=handle_incompatible,
            experiment_name="izmir",
            alignment_file=self.alignment_file_2,
            reference_name="hg38",
            lengths_file=self.in_ref_len_file,  # incomp lens
            annotation_file=self.in_annotation_file,  # incomp annot.
            metagene_radius=METAGENE_RADIUS,
            left_span=LEFT_SPAN,
            right_span=RIGHT_SPAN,
            length_min=2,
            length_max=5,
            nprocess=NPROCESS,
            tmp_file_prefix="")

        with self.assertRaises(ValueError):
            merge_ribos(ribo_out,
                        [self.handle, self.handle_2, handle_incompatible])
示例#9
0
    def setUp(self):

        self.tmp_files = list()

        self.ref_len_file = StringIO(GENERIC_TRANSCRIPT_LENGTHS)
        self.annotation_file = StringIO(GENERIC_TRANSCRIPT_ANNOTATION)
        self.alignment_file_1 = StringIO(READ_SET_1)
        self.alignment_file_2 = StringIO(READ_SET_2)

        self.handle_io = BytesIO()
        self.handle = h5py.File(self.handle_io, "w")
        self.handle_2 = h5py.File(BytesIO(), "w")
        self.h5_handle = h5py.File(BytesIO(), "w")

        initialize(self.h5_handle,
                   experiment_name="dummy",
                   reference_name="test_ref")

        (ref_names, ref_lengths) = \
           set_reference_names_and_lengths(self.h5_handle , self.ref_len_file)
        self.ref_len_file.seek(0)

        self.annotation_lines = GENERIC_TRANSCRIPT_ANNOTATION.split("\n")

        create.create_ribo(ribo=self.handle,
                           experiment_name="experiment-1",
                           alignment_file=self.alignment_file_1,
                           reference_name="hg38",
                           lengths_file=self.ref_len_file,
                           annotation_file=self.annotation_file,
                           metagene_radius=METAGENE_RADIUS,
                           left_span=LEFT_SPAN,
                           right_span=RIGHT_SPAN,
                           length_min=LENGTH_MIN,
                           length_max=LENGTH_MAX,
                           store_coverage=True,
                           nprocess=NPROCESS,
                           tmp_file_prefix="")

        self.handle.close()
        self.sample_ribo = Ribo(self.handle_io)

        # Get the  region counts

        self.cds_counts = \
           self.sample_ribo.get_region_counts( region_name    = CDS_name,
                                               sum_references = False)

        self.utr5_counts = \
           self.sample_ribo.get_region_counts( region_name    = UTR5_name,
                                               sum_references = False)

        self.utr3_counts = \
           self.sample_ribo.get_region_counts( region_name    = UTR3_name,
                                               sum_references = False)

        self.utr5j_counts = \
           self.sample_ribo.get_region_counts( region_name    = UTR5_JUNCTION_name,
                                               sum_references = False)

        self.utr3j_counts = \
           self.sample_ribo.get_region_counts( region_name    = UTR3_JUNCTION_name,
                                               sum_references = False)