178
180
stop = GetOffsetInLoc (cbp->loc, mrna->location, SEQLOC_STOP);
179
181
if (start < 0 || start >= ns.nuc->length ||
180
182
stop < 0 || stop >= ns.nuc->length) continue;
181
cbp->loc = SeqLocFree (cbp->loc);
182
cbp->loc = AddIntervalToLocation (NULL, sip, start, stop, partial5, partial3);;
183
cbp->loc = SeqLocFree (cbp->loc);
184
cbp->loc = AddIntervalToLocation (NULL, sip, start, stop, partial5, partial3);;
187
/* remove feature ID cross-references of original cds */
188
ClearFeatIDXrefs (sfp);
186
191
/* copy gene from contig onto nuc-prot, single interval on cdna bioseq */
355
363
gene = SeqMgrGetOverlappingGene (mrna->location, NULL);
356
364
if (gene != NULL) {
357
365
grp = (GeneRefPtr) gene->data.value.ptrvalue;
358
if (gene->id.choice == 1) {
359
(gene->id.value.intvalue)++;
360
sprintf (suffix, "_%ld", (long) gene->id.value.intvalue);
366
iptr = (Int4Ptr) gene->idx.scratch;
369
sprintf (suffix, "_%ld", (long) (*iptr));
376
static void InstantiateMrnaIntoProt (SeqFeatPtr cds, SeqFeatPtr mrna, Int2Ptr ctrp, Boolean ambig)
385
static SeqIdPtr MakeIdFromProtein (
390
Char buf [64], tmp [64];
393
if (pbsp == NULL) return NULL;
394
sip = SeqIdFindBestAccession (pbsp->id);
395
if (sip == NULL) return NULL;
396
SeqIdWrite (sip, buf, PRINTID_TEXTID_ACC_VER, sizeof (buf) - 1);
397
if (StringHasNoText (buf)) return NULL;
398
StringCpy (tmp, "gnl|MTRACK|");
399
StringCat (tmp, buf);
400
StringCat (tmp, "_mrna");
401
return MakeSeqID (tmp);
404
static void InstantiateMrnaIntoProt (
388
if (cds == NULL || mrna == NULL) return;
421
if (cds == NULL || mrna == NULL || ngp == NULL) return;
389
422
if (cds->product == NULL || mrna->product != NULL) return;
391
424
pbsp = BioseqFindFromSeqLoc (cds->product);
392
if (pbsp == NULL) return;
425
if (pbsp == NULL) return;
393
426
psep = SeqMgrGetSeqEntryForData (pbsp);
394
427
if (psep == NULL) return;
407
440
mbsp->repr = Seq_repr_raw;
408
441
mbsp->mol = Seq_mol_rna;
409
442
mbsp->seq_data_type = Seq_code_iupacna;
443
mbsp->seq_data = (SeqDataPtr) bs;
411
444
mbsp->length = BSLen (bs);
412
445
BioseqPack (mbsp);
447
/* now adds _# suffix to general Seq-id if ambiguous - but messed up Drosophila record, so only use feature ID */
416
mbsp->id = MakeIdFromLocusTag (mrna);
419
/* now adds _# suffix to general Seq-id if ambiguous */
420
449
mbsp->id = MakeIdFromLocusTag (mrna);
451
if (ngp->useProtID) {
452
mbsp->id = MakeIdFromProtein (pbsp);
421
454
if (mbsp->id == NULL) {
422
455
mbsp->id = MakeNewProteinSeqIdEx (mrna->location, NULL, NULL, ctrp);
452
485
AddSeqEntryToSeqEntry (psep, msep, FALSE);
455
static void RemoveFeatIDs (SeqFeatPtr sfp, Pointer userdata)
488
static void RemoveFeatScratch (
458
494
if (sfp == NULL) return;
459
if (sfp->id.choice == 1) {
461
sfp->id.value.intvalue = 0;
495
if (sfp->idx.scratch == NULL) return;
496
sfp->idx.scratch = MemFree (sfp->idx.scratch);
465
499
typedef struct loopdata {
469
502
} LoopData, PNTR LoopDataPtr;
528
565
sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
529
566
while (sfp != NULL) {
530
if (sfp->id.choice == 0) {
567
if (sfp->idx.scratch == NULL) {
534
570
count = SeqMgrGetAllOverlappingFeatures (sfp->location, FEATDEF_mRNA, NULL, 0,
535
571
CHECK_INTERVALS, (Pointer) &ld, FindSingleMrnaProc);
536
572
if (ld.count == 1 && ld.mrna != NULL) {
537
InstantiateMrnaIntoProt (sfp, ld.mrna, ctrp, ld.ambig);
539
ld.mrna->id.choice = 1;
573
InstantiateMrnaIntoProt (sfp, ld.mrna, ctrp, ngp);
574
sfp->idx.scratch = (Pointer) MemNew (sizeof (Int4));
575
ld.mrna->idx.scratch = (Pointer) MemNew (sizeof (Int4));
542
578
str = fcontext.label;
555
592
sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
556
593
while (sfp != NULL) {
557
if (sfp->id.choice == 0) {
594
if (sfp->idx.scratch == NULL) {
558
595
if (sfp->product == NULL && CdsIsPseudo (sfp)) {
559
596
/* do not complain about pseudo CDS not having product or matching mRNA */
575
static void NPStoGPS (Uint2 entityID, CharPtr filename, N2GPtr ngp, SeqDescrPtr descr)
612
static SeqFeatPtr GetmRNAByFeatureID (
617
SeqFeatPtr mRNA = NULL;
622
if (cds == NULL) return NULL;
625
while (xref != NULL && mRNA == NULL) {
626
if (xref->id.choice == 3) {
627
oip = (ObjectIdPtr) xref->id.value.ptrvalue;
629
if (StringDoesHaveText (oip->str)) {
630
mRNA = SeqMgrGetFeatureByFeatID (cds->idx.entityID, NULL, oip->str, NULL, NULL);
632
sprintf (buf, "%ld", (long) oip->id);
633
mRNA = SeqMgrGetFeatureByFeatID (cds->idx.entityID, NULL, buf, NULL, NULL);
642
static void NPStoGPS (
578
650
BioSourcePtr biop;
580
652
BioseqSetPtr bssp;
582
SeqMgrFeatContext gcontext, mcontext;
654
SeqMgrFeatContext fcontext, gcontext, mcontext;
583
655
SeqFeatPtr gene, mrna, sfp, lastsfp;
585
658
SeqEntryPtr old, top;
586
659
CharPtr organism;
652
724
if (grp == NULL) {
653
725
gene = SeqMgrGetOverlappingGene (mrna->location, NULL);
654
726
if (gene != NULL) {
655
if (gene->id.choice == 0) {
657
gene->id.value.intvalue = 1;
658
} else if (gene->id.choice == 1) {
659
(gene->id.value.intvalue)++;
727
iptr = (Int4Ptr) gene->idx.scratch;
729
iptr = (Int4Ptr) MemNew (sizeof (Int4));
730
gene->idx.scratch = (Pointer) iptr;
668
742
gene = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_GENE, 0, &gcontext);
669
743
while (gene != NULL) {
670
if (gene->id.choice == 1) {
671
if (gene->id.value.intvalue == 1) {
672
/* if count was 1, clear id */
673
gene->id.value.intvalue = 0;
744
iptr = (Int4Ptr) gene->idx.scratch;
747
/* if count was 1, clear scratch */
748
gene->idx.scratch = MemFree (gene->idx.scratch);
676
/* if count was > 1, just reset count, do not clear id */
677
gene->id.value.intvalue = 0;
750
/* if count was > 1, just reset count, do not clear scratch */
680
754
gene = SeqMgrGetNextFeature (bsp, gene, SEQFEAT_GENE, 0, &gcontext);
684
sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
685
while (sfp != NULL) {
686
mrna = SeqMgrGetOverlappingFeature (sfp->location, FEATDEF_mRNA, NULL, 0,
687
NULL, CHECK_INTERVALS, &mcontext);
689
InstantiateMrnaIntoProt (sfp, mrna, &ctr);
759
/* trust feature ID cross-references */
761
sfp = SeqMgrGetNextFeature (bsp, NULL, SEQFEAT_CDREGION, 0, &fcontext);
762
while (sfp != NULL) {
763
mrna = GetmRNAByFeatureID (sfp);
765
InstantiateMrnaIntoProt (sfp, mrna, &ctr, ngp);
767
sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_CDREGION, 0, &fcontext);
691
sfp = SeqMgrGetNextFeature (bsp, sfp, SEQFEAT_CDREGION, 0, &fcontext);
772
/* make cDNA bioseq from mRNA feature, package with protein product */
774
LoopThroughCDSs (bsp, &ctr, ngp);
695
/* make cDNA bioseq from mRNA feature, package with protein product */
697
LoopThroughCDSs (bsp, &ctr, ngp);
777
VisitFeaturesInSep (top, NULL, RemoveFeatScratch);
699
779
SeqMgrLinkSeqEntry (top, parenttype, parentptr);
703
783
SeqMgrClearFeatureIndexes (bssp->idx.entityID, NULL);
705
VisitFeaturesInSep (top, NULL, RemoveFeatIDs);
707
785
/* need to reindex to get mRNA and CDS features from cDNA and protein */
708
786
SeqMgrIndexFeatures (bssp->idx.entityID, NULL);
709
787
VisitSetsInSet (bssp, NULL, LclMakeNucProtCDS);
925
1005
TRUE, 'R', ARG_BOOLEAN, 0.0, 0, NULL},
926
1006
{"Lock Components in Advance", "F", NULL, NULL,
927
1007
TRUE, 'L', ARG_BOOLEAN, 0.0, 0, NULL},
1008
{"Map by Feature ID", "F", NULL, NULL,
1009
TRUE, 'F', ARG_BOOLEAN, 0.0, 0, NULL},
1010
{"mRNA ID from Protein", "F", NULL, NULL,
1011
TRUE, 'P', ARG_BOOLEAN, 0.0, 0, NULL},
930
1014
Int2 Main (void)