def build_transcript_dictionary(seqs, genes):
    transcripts = {}

    for gene in genes:
        gene = Gene.from_gff_feature(gene)
        if gene == None:
            print("Could not convert GFFFeature to Gene, skipping")
            continue

        new_mrnas = []
        for mrna in gene['mrna']:
            mrna = Mrna.from_gff_feature(mrna)
            if mrna == None:
                print("Could not convert GFFFeature to Mrna, skipping")
                continue
            new_mrnas.append(mrna)
        gene.children['mrna'] = new_mrnas

        if gene.seqid in transcripts:
            transcripts[gene.seqid].genes.append(gene)
        else:
            if gene.seqid in seqs:
                transcripts[gene.seqid] = Transcript([gene], seqs[gene.seqid])
            else:
                print("Gene "+gene.attributes["ID"]+" is on sequence "+gene.seqid+" which does not exist. Skipping...")

    return transcripts
 def test_from_gff_features_fails(self):
     gff_gene = Mock()
     gff_gene.type = "asdf"
     
     tran_gene = Gene.from_gff_feature(gff_gene)
     self.assertFalse(tran_gene)
 def test_from_gff_feature_success(self):
     gff_gene = Mock()
     gff_gene.type = "gene"
     
     tran_gene = Gene.from_gff_feature(gff_gene)
     self.assertTrue(tran_gene)