char *RawContig_getSubSeq(RawContig *contig, int start, int end, int strand) { SequenceAdaptor *sa; if (end < start) { fprintf(stderr, "Error: End coord is less then start coord to call on RawContig subseq."); exit(1); } if (strand != -1 && strand != 1) { strand = 1; } // if the sequence of this contig has been manually set retrieve its substring if (contig->seq) { char *str = StrUtil_substr(contig->seq, start-1, end - start + 1); if (strand == -1) { SeqUtil_reverseComplement(str,strlen(str)); } return str; } if (!RawContig_getAdaptor(contig)) { fprintf(stderr, "Error: RawContig subseq no sequence set and no db available\n"); return emptyString; } sa = DBAdaptor_getSequenceAdaptor(RawContig_getAdaptor(contig)->dba->dnadb); //return SequenceAdaptor_fetchByRawContigStartEndStrand(sa, RawContig_getDbID(contig), start, end, strand); return NULL; }
int main(int argc, char *argv[]) { DBAdaptor *dba; Slice *slice; SliceAdaptor *sliceA; SequenceAdaptor *seqA; initEnsC(argc, argv); dba = DBAdaptor_new("ensembldb.ensembl.org","anonymous",NULL,"homo_sapiens_core_70_37",5306,NULL); //dba = DBAdaptor_new("ens-livemirror.internal.sanger.ac.uk","ensro",NULL,"homo_sapiens_core_70_37",3306,NULL); //dba = DBAdaptor_new("genebuild2.internal.sanger.ac.uk","ensadmin","ensembl","steve_hs_testdb",3306,NULL); sliceA = DBAdaptor_getSliceAdaptor(dba); seqA = DBAdaptor_getSequenceAdaptor(dba); // // Test fetch_by_Slice_start_end_strand // slice = SliceAdaptor_fetchByRegion(sliceA,"chromosome",CHR,START,END,STRAND,NULL,0); compareComplements(slice, seqA); slice = SliceAdaptor_fetchByRegion(sliceA, "clone","AL031658.11", POS_UNDEF, POS_UNDEF, STRAND_UNDEF, NULL, 0); compareComplements(slice, seqA); slice = SliceAdaptor_fetchByRegion(sliceA, "supercontig","NT_028392", POS_UNDEF, POS_UNDEF, STRAND_UNDEF, NULL, 0); compareComplements(slice, seqA); slice = SliceAdaptor_fetchByRegion(sliceA, "contig", "AL031658.11.1.162976", POS_UNDEF, POS_UNDEF, STRAND_UNDEF, NULL, 0); compareComplements(slice, seqA); return 0; }
char *RawContig_getSeq(RawContig *contig) { if (contig->seq) { return contig->seq; } //or retrieved from the database if (RawContig_getAdaptor(contig)) { DBAdaptor *dnadba; SequenceAdaptor *sa; dnadba = RawContig_getAdaptor(contig)->dba->dnadb; sa = DBAdaptor_getSequenceAdaptor(dnadba); //return SequenceAdaptor_fetchByRawContigStartEndStrand(sa, RawContig_getDbID(contig), 1, -1, 1); return NULL; } fprintf(stderr,"Warning: RawContig seq not set, and no db is available\n"); return emptyString; }