~ubuntu-branches/ubuntu/edgy/ncbi-tools6/edgy

« back to all changes in this revision

Viewing changes to desktop/seqpanel.c

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2006-07-19 23:28:07 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20060719232807-et3cdmcjgmnyleyx
Tags: 6.1.20060507-3ubuntu1
Re-merge with Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: seqpanel.c,v 6.169 2005/11/08 19:39:30 bollin Exp $
 
1
/* $Id: seqpanel.c,v 6.182 2006/02/02 18:05:09 bollin Exp $
2
2
* ===========================================================================
3
3
*
4
4
*                            PUBLIC DOMAIN NOTICE
44
44
#include <subutil.h>
45
45
#include <actutils.h>
46
46
#include <algo/blast/api/twoseq_api.h>
 
47
#include <algo/blast/api/blast_seqalign.h>
47
48
#include <alignval.h>
 
49
#include <salptool.h>
48
50
 
49
51
enum ESeqNum   { eNumNone=1, eNumSide=2, eNumTop=3 };
50
52
enum EDrawGrid { eDrawGridOn=1, eDrawGridOff=2 };
60
62
#define SEQ_GROUP_SIZE       10  /* Sequence group size           */
61
63
#define SEQ_X_OFFSET          4
62
64
#define SEQ_Y_OFFSET          4
63
 
#define ALNMGR_GAP           -2
64
65
#define ROW_UNDEFINED        -1
65
66
#define PROT_PRODUCT_TYPE   255
66
67
#define PROT_ON_THE_FLY     254
159
160
                                             
160
161
  MenU              aln_target_menu;        /* This is used by the alignment editor to
161
162
                                             * change the target.
162
 
                                             */                                                                                     
 
163
                                             */   
 
164
 
 
165
  SeqAnnotPtr       annot;                  /* This is the annotation that should point
 
166
                                             * to our alignment.  If it does not, the
 
167
                                             * alignment has been replaced.
 
168
                                             */                                                                                                                               
163
169
  
164
170
} SeqEdFormData, PNTR SeqEdFormPtr;
165
171
 
419
425
      Int4    fLeft    = x_FeatLeft (bvp, fcontext.left, aln_row);
420
426
      Int4    fRight   = x_FeatRight(bvp, fcontext.right, aln_row); 
421
427
      
 
428
      if (fLeft < 0) fLeft = 0;
 
429
      
422
430
      if (aln_strand == Seq_strand_minus)
423
431
      {
424
432
        /* if the alignment strand is reversed, the left and right endpoints will be
555
563
                                       * so that we don't have to fetch
556
564
                                       * far pointers over and over again
557
565
                                       */                                       
558
 
  BioseqPtr PNTR PNTR bioseqs_for_each_aln = NULL;                                       
 
566
  BioseqPtr PNTR PNTR bioseqs_for_each_aln = NULL; 
 
567
  Int4                para_num;                                      
559
568
  
560
569
  if (bvp->seqAlignMode) {
561
570
    /* if this is in alignment mode, get the list of sequences for each 
651
660
  bvp->TotalLines = 0; /* go through all pararaphs and count total */
652
661
  if (bvp->seqAlignMode)
653
662
  {
 
663
    para_num = 0;
654
664
    for (tmp_salp = bvp->salp, aln_idx = 0; tmp_salp != NULL; tmp_salp = tmp_salp->next, aln_idx ++)
655
665
    {
656
666
      /* add lines for features */
657
 
      for (i = 0; i < lines_per_alignment [aln_idx]; i++) {
 
667
      for (i = 0; i < lines_per_alignment [aln_idx]; i++) 
 
668
      {
658
669
        Int4 sub_total = 0;
659
 
        for (j = 0; j < featRows; j++) sub_total += ValNodeLen(ref[i]->pFeatList[j]); 
 
670
        for (j = 0; j < featRows; j++) 
 
671
        {
 
672
          sub_total += ValNodeLen(ref[i + para_num]->pFeatList[j]); 
 
673
        }
660
674
        bvp->TotalLines += fLines + sub_total + (alnRows == -1 ? 0 : alnValidRows[aln_idx]); /* reserve space for alignment */
661
675
      }
662
676
      /* add one more for divider */
663
677
      if (tmp_salp->next != NULL) bvp->TotalLines ++;
 
678
      para_num += lines_per_alignment [aln_idx];
664
679
    }
665
680
        
666
681
  }
1070
1085
}
1071
1086
 
1072
1087
 
1073
 
static void DrawAlignSideLineNumbers(Int2 x, Int2 y, Int4 line, Int4 row, BioseqViewPtr bvp)
 
1088
static void 
 
1089
DrawAlignSideLineNumbers
 
1090
(Int2          x, 
 
1091
 Int2          y, 
 
1092
 Int4          line, 
 
1093
 Int4          row, 
 
1094
 BioseqViewPtr bvp,
 
1095
 Int4          aln_idx)
1074
1096
{
1075
 
  char buf[20];
1076
 
  Int4 aln_pos = line * bvp->CharsAtLine + 1;
1077
 
  Int4 pos = AlnMgr2MapSeqAlignToBioseq(bvp->salp, aln_pos, row);
1078
 
  
1079
 
  while (pos == ALNMGR_GAP && aln_pos > 1) { /* count back if we in the gap */
 
1097
  char        buf[20];
 
1098
  Int4        aln_pos = line * bvp->CharsAtLine + 1;
 
1099
  Int4        seq_pos;
 
1100
  Int4        i;
 
1101
  SeqAlignPtr tmp_salp;
 
1102
  
 
1103
  for (i=0, tmp_salp = bvp->salp; i < aln_idx && tmp_salp != NULL; i++, tmp_salp = tmp_salp->next)
 
1104
  {     
 
1105
  }
 
1106
  if (tmp_salp == NULL) return;
 
1107
 
 
1108
  seq_pos = AlnMgr2MapSeqAlignToBioseq(tmp_salp, aln_pos, row);
 
1109
  
 
1110
  while (seq_pos == ALNMGR_GAP && aln_pos > 1) { /* count back if we in the gap */
1080
1111
    aln_pos--;
1081
 
    pos = AlnMgr2MapSeqAlignToBioseq(bvp->salp, aln_pos, row);
 
1112
    seq_pos = AlnMgr2MapSeqAlignToBioseq(bvp->salp, aln_pos, row);
1082
1113
  }
1083
 
  if (pos == ALNMGR_GAP) pos = 1;  /* Gap at the begining of the alignment */
 
1114
  if (seq_pos == ALNMGR_GAP) seq_pos = 1;  /* Gap at the begining of the alignment */
1084
1115
  
1085
 
  sprintf(buf, "%d", pos); /* In alignment coordinates */
 
1116
  sprintf(buf, "%d", seq_pos); /* In alignment coordinates */
1086
1117
 
1087
1118
  Magenta ();
1088
1119
  SelectFont ((FonT)(bvp->displayFont));    
1090
1121
}
1091
1122
 
1092
1123
 
1093
 
static SeqPortPtr SeqPortFromAlignmentInterval (Int4 seqstart, Int4 seqstop, Uint1 strand, BioseqPtr bsp)
1094
 
{
1095
 
  SeqIntPtr  sinp;
1096
 
  SeqLocPtr  slp;
1097
 
  SeqPortPtr spp;
1098
 
 
1099
 
  if (bsp == NULL) return NULL;
1100
 
  sinp = SeqIntNew();
1101
 
  if (sinp == NULL) return NULL;
1102
 
  sinp->from = seqstart;
1103
 
  sinp->to = seqstop;
1104
 
  sinp->strand = strand;
1105
 
  sinp->id = SeqIdDup (SeqIdFindBest (bsp->id, 0));
1106
 
  slp = ValNodeNew (NULL);
1107
 
  if (slp == NULL) {
1108
 
    SeqIntFree (sinp);
1109
 
    return NULL;
1110
 
  }
1111
 
  slp->choice = SEQLOC_INT;
1112
 
  slp->data.ptrvalue = (Pointer) sinp;
1113
 
  spp = SeqPortNewByLoc (slp, Seq_code_iupacna);
1114
 
  SeqLocFree (slp);
1115
 
  return spp;
1116
 
}
1117
 
 
1118
 
static void SetSequenceIntervalBuf
1119
 
(SeqAlignPtr salp,
1120
 
 BioseqPtr   bsp,
1121
 
 Int4        row,
1122
 
 Int4        start,                             
1123
 
 Int4        stop,
1124
 
 Int4Ptr     seqstart,
1125
 
 Int4Ptr     seqstop,
1126
 
 Int4        aln_len,                             
1127
 
 Uint1Ptr    target_buf)
1128
 
{
1129
 
  Int4       buf_len = stop - start + 1;
1130
 
  Uint1      strand;
1131
 
  Int4       i;
1132
 
  SeqPortPtr spp;
1133
 
 
1134
 
  if (seqstart == NULL || seqstop == NULL)
1135
 
  {
1136
 
    return;
1137
 
  }
1138
 
  
1139
 
  *seqstart = ALNMGR_GAP;
1140
 
  *seqstop = ALNMGR_GAP;
1141
 
  if (bsp == NULL)
1142
 
  {
1143
 
    return;
1144
 
  }
1145
 
  strand = SeqAlignStrand (salp, row - 1);
1146
 
  MemSet (target_buf, 0, buf_len);
1147
 
  /* if this is a minus strand sequence, start is stop and stop is start */
1148
 
  if (strand == Seq_strand_minus) {
1149
 
    *seqstop = AlnMgr2MapSeqAlignToBioseq(salp, start, row);
1150
 
    *seqstart  = AlnMgr2MapSeqAlignToBioseq(salp, stop, row);
1151
 
  } else {
1152
 
    *seqstart = AlnMgr2MapSeqAlignToBioseq(salp, start, row);
1153
 
    *seqstop  = AlnMgr2MapSeqAlignToBioseq(salp, stop, row);
1154
 
  }
1155
 
 
1156
 
  if (strand == Seq_strand_minus) {
1157
 
    i = stop;
1158
 
    while (*seqstart == ALNMGR_GAP && i > 0) { /* count backward if we are in the gap */
1159
 
      i--;
1160
 
      *seqstart = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1161
 
    }
1162
 
  } else {
1163
 
    i = start;
1164
 
    while (*seqstart == ALNMGR_GAP && i < aln_len) { /* count forward if we in the gap */
1165
 
      i++;
1166
 
      *seqstart = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1167
 
    }
1168
 
  }
1169
 
  if (*seqstop == -1 || *seqstop>=bsp->length) *seqstop = bsp->length - 1;  /* -1 means exeed sequence length */
1170
 
  
1171
 
  if (strand == Seq_strand_minus) {
1172
 
    i = start;
1173
 
    while (*seqstop == ALNMGR_GAP && i > 0) { /* count backward if we are in the gap */
1174
 
      i--;
1175
 
      *seqstop = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1176
 
    }
1177
 
  } else {
1178
 
    i = stop;
1179
 
    while (*seqstop == ALNMGR_GAP && i < aln_len) { /* count forward if we are in the gap */
1180
 
      i++;
1181
 
      *seqstop = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1182
 
    }
1183
 
  }
1184
 
  
1185
 
  if (*seqstart == ALNMGR_GAP  &&  *seqstop == ALNMGR_GAP) {
1186
 
    return;
1187
 
  }
1188
 
  if (*seqstop  < 0) *seqstop  = bsp->length - 1;
1189
 
  if (*seqstart < 0) *seqstart = *seqstop;
1190
 
  if (strand == Seq_strand_minus) {
1191
 
    if (*seqstop - *seqstart > buf_len) 
1192
 
      *seqstart = *seqstop - buf_len;
1193
 
  } else {
1194
 
    if (*seqstop - *seqstart > buf_len) *seqstop = *seqstart + buf_len;  /* not to exeed the current line */
1195
 
  }
1196
 
 
1197
 
  spp = SeqPortFromAlignmentInterval (*seqstart, *seqstop, strand, bsp);
1198
 
  SeqPortRead  (spp, target_buf, *seqstop - *seqstart + 1);
1199
 
  SeqPortFree  (spp);
1200
 
}
1201
 
 
1202
 
 
1203
 
static void 
1204
 
AlignmentIntervalToString 
1205
 
(SeqAlignPtr salp,
1206
 
 Int4        row,
1207
 
 Int4        start,
1208
 
 Int4        stop,
1209
 
 Int4        target_row,
1210
 
 Boolean     view_whole_entity,
1211
 
 Uint1Ptr    seqbuf,
1212
 
 Uint1Ptr    alnbuf,
1213
 
 Int4 PNTR   alnbuffer_len,
1214
 
 Boolean     show_substitutions)
1215
 
{
1216
 
  Int4       aln_len = AlnMgr2GetAlnLength(salp, FALSE);
1217
 
  SeqIdPtr   sip     = AlnMgr2GetNthSeqIdPtr(salp, row);
1218
 
  BioseqPtr  bsp     = BioseqLockById(sip);
1219
 
  Int4       alnbuf_len = stop - start + 1;
1220
 
  Uint1      strand;
1221
 
  Int4       seqstart, seqstop;
1222
 
  Int4       i, k;
1223
 
  SeqPortPtr spp;
1224
 
  Int4       seq_len;
1225
 
  Uint1      target_strand;
1226
 
  SeqIdPtr   sip_target;
1227
 
  BioseqPtr  bsp_target;
1228
 
  Int4       target_start;
1229
 
  Int4       target_stop;
1230
 
  Uint1Ptr   target_buf;
1231
 
  Int4       aln_pos;
1232
 
 
1233
 
  MemSet(alnbuf, '-', alnbuf_len); /* assume all gaps and fill the sequence later */
1234
 
  MemSet(seqbuf, 0, alnbuf_len);
1235
 
  if (target_row < 0) return;
1236
 
  
1237
 
  if (stop > aln_len && start > aln_len)
1238
 
  {
1239
 
    aln_len = AlnMgr2GetAlnLength(salp, FALSE);
1240
 
    return;
1241
 
  }
1242
 
 
1243
 
  if (stop > aln_len) {
1244
 
    MemSet (alnbuf + aln_len - start, 0, stop - aln_len);
1245
 
    stop = aln_len - 1;
1246
 
    alnbuf_len = stop - start + 1;
1247
 
  }
1248
 
 
1249
 
  if (alnbuffer_len != NULL) {
1250
 
    *alnbuffer_len = alnbuf_len;
1251
 
  }
1252
 
 
1253
 
  strand = SeqAlignStrand (salp, row - 1);
1254
 
  target_strand = SeqAlignStrand (salp, target_row - 1);
1255
 
  /* if this is a minus strand sequence, start is stop and stop is start */
1256
 
  if (strand == Seq_strand_minus) {
1257
 
    seqstop = AlnMgr2MapSeqAlignToBioseq(salp, start, row);
1258
 
    seqstart  = AlnMgr2MapSeqAlignToBioseq(salp, stop,  row);
1259
 
  } else {
1260
 
    seqstart = AlnMgr2MapSeqAlignToBioseq(salp, start, row);
1261
 
    seqstop  = AlnMgr2MapSeqAlignToBioseq(salp, stop,  row);
1262
 
  }
1263
 
  
1264
 
  if (strand == Seq_strand_minus) {
1265
 
    i = stop;
1266
 
    while (seqstart == ALNMGR_GAP && i > 0) { /* count backward if we are in the gap */
1267
 
      i--;
1268
 
      seqstart = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1269
 
    }
1270
 
  } else {
1271
 
    i = start;
1272
 
    while (seqstart == ALNMGR_GAP && i < aln_len) { /* count forward if we in the gap */
1273
 
      i++;
1274
 
      seqstart = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1275
 
    }
1276
 
  }
1277
 
  
1278
 
  if (seqstop == -1 || seqstop>=bsp->length)
1279
 
  {
1280
 
    seqstop = bsp->length - 1;  /* -1 means exeed sequence length */
1281
 
  }
1282
 
  
1283
 
  if (strand == Seq_strand_minus) {
1284
 
    i = start;
1285
 
    while (seqstop == ALNMGR_GAP && i > 0) { /* count backward if we are in the gap */
1286
 
      i--;
1287
 
      seqstop = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1288
 
    }
1289
 
  } else {
1290
 
    i = stop;
1291
 
    while (seqstop == ALNMGR_GAP && i < aln_len) { /* count forward if we are in the gap */
1292
 
      i++;
1293
 
      seqstop = AlnMgr2MapSeqAlignToBioseq(salp, i, row);
1294
 
    }
1295
 
  }
1296
 
  
1297
 
  if (seqstart == ALNMGR_GAP  &&  seqstop == ALNMGR_GAP) seqstart = seqstop = 0;  /* whole line are gaps */
1298
 
  if (seqstop  < 0) seqstop  = bsp->length - 1;
1299
 
  if (seqstart < 0) seqstart = seqstop;
1300
 
  if (strand == Seq_strand_minus) {
1301
 
    if (seqstop - seqstart > alnbuf_len)
1302
 
    {
1303
 
      seqstart = seqstop - alnbuf_len;
1304
 
    }
1305
 
  } else {
1306
 
    if (seqstop - seqstart > alnbuf_len) 
1307
 
    {
1308
 
      seqstop = seqstart + alnbuf_len;  /* not to exeed the current line */
1309
 
    }
1310
 
  }
1311
 
 
1312
 
  spp = SeqPortFromAlignmentInterval (seqstart, seqstop, strand, bsp);
1313
 
  SeqPortRead  (spp, seqbuf, seqstop - seqstart + 1);
1314
 
  if (seqbuf [stop - start] == 0) {
1315
 
    seq_len = StringLen ((CharPtr) seqbuf);
1316
 
  } else {
1317
 
    seq_len = stop - start + 1;
1318
 
  }
1319
 
  SeqPortFree  (spp);
1320
 
  BioseqUnlock (bsp);
1321
 
  SeqIdFree    (sip);
1322
 
 
1323
 
  if (row != target_row  &&  ! view_whole_entity  &&  target_row != ROW_UNDEFINED)  {
1324
 
    sip_target = AlnMgr2GetNthSeqIdPtr(salp, target_row);
1325
 
    bsp_target = BioseqLockById(sip_target);
1326
 
 
1327
 
    target_buf = (Uint1Ptr) MemNew (stop - start + 1);
1328
 
    MemSet (target_buf, 0, stop - start + 1);
1329
 
    if (target_buf != NULL) {
1330
 
      SetSequenceIntervalBuf (salp, bsp_target, target_row, start, stop, 
1331
 
                              &target_start, &target_stop, aln_len, target_buf);
1332
 
    }
1333
 
  } else {
1334
 
    sip_target = NULL;
1335
 
    bsp_target = NULL;
1336
 
    target_buf = NULL;
1337
 
  }
1338
 
 
1339
 
  k = 0;
1340
 
  i = 0;
1341
 
 
1342
 
  for (aln_pos = start; aln_pos <= stop; aln_pos ++) {
1343
 
    Int4 seq_pos = AlnMgr2MapSeqAlignToBioseq(salp, aln_pos, row);
1344
 
    Int4 target_pos = AlnMgr2MapSeqAlignToBioseq(salp, aln_pos, target_row);
1345
 
 
1346
 
    if (seq_pos >= 0) {
1347
 
      alnbuf [aln_pos - start] = TO_LOWER (seqbuf[k]);
1348
 
      if (show_substitutions)
1349
 
      {
1350
 
        /* Handle mismatches (insert dots when matched) */
1351
 
        if (row != target_row  &&  ! view_whole_entity  &&  target_row != ROW_UNDEFINED)  {
1352
 
          if(target_pos >= 0  && target_pos < bsp_target->length) { /* no gap in the target sequence */
1353
 
            if (seqbuf[k] == target_buf[i]) {
1354
 
              alnbuf[aln_pos - start] = GAP_CHAR;
1355
 
            }
1356
 
          }
1357
 
        }   /* mismatches */
1358
 
      }
1359
 
      k++;
1360
 
    }
1361
 
    if (target_pos >= 0) {
1362
 
      i++;
1363
 
    }
1364
 
  }    
1365
 
 
1366
 
  if (alnbuf[alnbuf_len] == 0) {
1367
 
    *alnbuffer_len = StringLen ((CharPtr) alnbuf);
1368
 
  }
1369
 
 
1370
 
  if (bsp_target != NULL) {
1371
 
    BioseqUnlock (bsp_target);
1372
 
  }
1373
 
  if (sip_target != NULL) {
1374
 
    SeqIdFree (sip_target);
1375
 
  }
1376
 
  if (target_buf != NULL) {
1377
 
    MemFree (target_buf);
1378
 
  }
1379
 
}
1380
 
 
1381
 
 
1382
1124
 
1383
1125
static void DrawAlignment
1384
1126
(Int2 x, Int2 y, Int4 line, Int4 row, Uint1Ptr buf, Uint1Ptr seqbuf,
1403
1145
  if (tmp_salp == NULL) return;
1404
1146
  sip = AlnMgr2GetNthSeqIdPtr(tmp_salp, row);
1405
1147
  bsp = BioseqLockById(sip);
 
1148
  if (bsp == NULL) return;
1406
1149
 
1407
1150
  AlignmentIntervalToString (tmp_salp, row, start, stop, bvp->TargetRow,
1408
1151
                             bvp->viewWholeEntity, seqbuf, alnbuf, &alnbuf_len,
2678
2421
          if (bvp->DrawGrid) DrawLtGrid(x, y+bvp->LineSpace/2, r.right, y+bvp->LineSpace/2);
2679
2422
          break;
2680
2423
        case eTypeAlignSequence:
2681
 
          DrawAlignSideLineNumbers(x, y, splp->bioSeqLine, splp->row, bvp);
 
2424
          DrawAlignSideLineNumbers(x, y, splp->bioSeqLine, splp->row, bvp, aln_idx);
2682
2425
          DrawAlignment(x, y, splp->bioSeqLine, splp->row, buf, seqbuf, alnbuf, bvp, aln_idx);                /* Draw the alignment   */
2683
2426
          if (bvp->DrawGrid) DrawLtGrid(x, y+bvp->LineSpace/2, r.right, y+bvp->LineSpace/2);
2684
2427
          if (bvp->last_aln_row_clicked == splp->row)
2799
2542
  return pnl;
2800
2543
}
2801
2544
 
 
2545
extern void UpdateSeqViewPanel (PaneL pnl)
 
2546
{
 
2547
  BioseqViewPtr bvp;
 
2548
  WindoW        currentport, temport;
 
2549
 
 
2550
  bvp = GetBioseqViewPtr(pnl);
 
2551
  if (bvp == NULL) return;
 
2552
  
 
2553
  bvp->salp = SeqAlignFree (bvp->salp);
 
2554
  if (Visible (bvp->seqView))
 
2555
  {
 
2556
    PopulateAlnView (bvp);
 
2557
    currentport = ParentWindow (bvp->seqView);
 
2558
    temport = SavePort (currentport);
 
2559
    Select (bvp->seqView);
 
2560
    inval_panel (bvp->seqView, -1, -1);
 
2561
    RestorePort (temport);
 
2562
  }
 
2563
}
 
2564
 
2802
2565
/* New Sequence Editor Functions */
2803
2566
 
2804
2567
/* This section of the code is for the new sequence editor.
6516
6279
  Int4                  gap_type, gap_len;
6517
6280
  Boolean               is_unknown_gap;
6518
6281
  Boolean               changed = FALSE;
 
6282
  Char                  len_text [20];
6519
6283
 
6520
6284
  sefp = (SeqEdFormPtr) GetObjectExtra (i);
6521
6285
  if (sefp == NULL || sefp->edit_pos_start < 0)
6532
6296
  RadioButton (gap_type_grp, "Known length:");
6533
6297
  k = HiddenGroup (g, 0, 2, NULL);
6534
6298
  StaticPrompt (k, "", 0, popupMenuHeight, programFont, 'l');
6535
 
  gap_len_txt = DialogText (k, "100", 5, NULL);
 
6299
  if (sefp->edit_pos_end > sefp->edit_pos_start)
 
6300
  {
 
6301
    sprintf (len_text, "%d", sefp->edit_pos_end - sefp->edit_pos_start);
 
6302
  }
 
6303
  else
 
6304
  {
 
6305
    sprintf (len_text, "100");
 
6306
  }
 
6307
  gap_len_txt = DialogText (k, len_text, 5, NULL);
6536
6308
  
6537
6309
  SetObjectExtra (gap_type_grp, gap_len_txt, NULL);
6538
6310
  SetValue (gap_type_grp, 1);
7670
7442
  Uint2     entityID;
7671
7443
  Int4      real_start, real_stop;
7672
7444
  Int4      aln_len;
7673
 
  Uint2     strand;
 
7445
  Uint1     strand;
7674
7446
  
7675
7447
  if (sefp == NULL || sefp->edit_pos_start == sefp->edit_pos_end || target_bsp == NULL) 
7676
7448
  {
8023
7795
  switch (ommsp->message) 
8024
7796
  {
8025
7797
      case OM_MSG_UPDATE:
 
7798
          if (sefp->bfp->bvd.seqAlignMode && sefp->annot != NULL
 
7799
              && sefp->annot->type == 2)
 
7800
          {
 
7801
            sefp->bfp->bvd.salp = sefp->annot->data;
 
7802
          }
8026
7803
          ResizeSeqEdView (sefp);
8027
7804
          Select (sefp->bfp->bvd.seqView);
8028
7805
          inval_panel (sefp->bfp->bvd.seqView, -1, -1); 
8935
8712
static SeqLocPtr GetSeqLocForAlignmentEdit (SeqEdFormPtr sefp)
8936
8713
{
8937
8714
  Int4 real_start, real_stop, aln_len;
8938
 
  Uint2 strand;
 
8715
  Uint1 strand;
8939
8716
  SeqLocPtr slp;
8940
8717
  SeqIdPtr  sip;
8941
8718
  
9112
8889
  
9113
8890
}
9114
8891
 
9115
 
static void CreateAlnMenus (WindoW w, Boolean enable_feat_prop)
 
8892
static void CreateAlnMenus (WindoW w, Boolean enable_feat_prop, Boolean allow_feat)
9116
8893
 
9117
8894
{
9118
8895
  MenU            edit_menu;
9163
8940
  edit_menu = PulldownMenu (w, "Features");
9164
8941
  sub = SubMenu (edit_menu, "Apply To Target Sequence");
9165
8942
  SeqEdNewFeaturesMenu (sub, TRUE);
 
8943
  if (!allow_feat)
 
8944
  {
 
8945
    Disable (sub);
 
8946
  }
9166
8947
 
9167
8948
  sub = SubMenu (edit_menu, "Apply To Alignment");
9168
8949
  localItem = CommandItem (sub, "CDS", ApplyCDSToAlignment);
9171
8952
  SetObjectExtra (localItem, sefp, NULL);
9172
8953
  localItem = CommandItem (sub, "Other Feature", ApplyOtherFeatureToAlignment);
9173
8954
  SetObjectExtra (localItem, sefp, NULL);
9174
 
  
 
8955
  if (!allow_feat)
 
8956
  {
 
8957
    Disable (sub);
 
8958
  }
9175
8959
  
9176
8960
}
9177
8961
 
9200
8984
    return NULL;
9201
8985
  }
9202
8986
  
 
8987
  sefp->annot = GetSeqAnnotForAlignment (salp);
 
8988
  
9203
8989
#ifdef WIN_MAC
9204
8990
  font = ParseFont ("Monaco, 9");
9205
8991
#endif
9247
9033
  sefp->bfp->bvd.on_the_fly = FALSE;
9248
9034
  sefp->bfp->bvd.showAlnSubstitutions = FALSE;
9249
9035
 
9250
 
  CreateAlnMenus (w, IsAlignmentOnSet (sefp->bfp->bvd.salp));
 
9036
  CreateAlnMenus (w, IsAlignmentOnSet (sefp->bfp->bvd.salp), (Boolean)(salp->segtype == SAS_DENSEG));
9251
9037
   
9252
9038
        btns_across = 4;
9253
9039
  sefp->upper_button_group = HiddenGroup (w, -10, -10, NULL);
9995
9781
   return salp;
9996
9782
}
9997
9783
 
 
9784
static SeqAlignPtr LIBCALLBACK GetSeqAlignPiece (SeqLocPtr slp1, SeqLocPtr slp2)
 
9785
{
 
9786
   BLAST_SummaryOptions *options = NULL;
 
9787
   SBlastSeqalignArray * seqalign_arr=NULL;
 
9788
   SeqAlignPtr           salp = NULL;
 
9789
   BioseqPtr             bsp;
 
9790
   
 
9791
   if (slp1 == NULL || slp2 == NULL) return NULL;
 
9792
 
 
9793
 
 
9794
   bsp = BioseqFindFromSeqLoc (slp1);
 
9795
   if (bsp == NULL)
 
9796
   {
 
9797
     return NULL;
 
9798
   }
 
9799
   
 
9800
   BLAST_SummaryOptionsInit(&options);
 
9801
   
 
9802
   if (ISA_na (bsp->mol))
 
9803
   {
 
9804
     options->program = eBlastn;
 
9805
   }
 
9806
   else
 
9807
   {
 
9808
     options->program = eBlastp;
 
9809
   }
 
9810
 
 
9811
   options->gapped_calculation = TRUE;
 
9812
   options->cutoff_evalue = 10;
 
9813
   options->gap_x_dropoff = 100;
 
9814
   options->gap_open = 4;
 
9815
   options->gap_extend = 1;
 
9816
   options->nucleotide_mismatch = -1; 
 
9817
   options->word_size = 7;
 
9818
 
 
9819
   BLAST_TwoSeqLocSets(options, slp1, slp2, NULL, &seqalign_arr, NULL, NULL, NULL);
 
9820
   
 
9821
   if (seqalign_arr != NULL)
 
9822
   {
 
9823
     salp = seqalign_arr->array[0];
 
9824
     seqalign_arr->array[0] = NULL;
 
9825
     seqalign_arr = SBlastSeqalignArrayFree(seqalign_arr);
 
9826
   }
 
9827
    
 
9828
   BLAST_SummaryOptionsFree(options);
 
9829
   return salp;
 
9830
}
 
9831
 
9998
9832
NLM_EXTERN SeqAlignPtr Sequin_GlobalAlign2Seq (BioseqPtr bsp1, BioseqPtr bsp2, BoolPtr revcomp)
9999
9833
{
10000
 
   return Sqn_GlobalAlign2SeqEx (bsp1, bsp2, revcomp, GetSeqAlign);
 
9834
   return Sqn_GlobalAlign2SeqEx (bsp1, bsp2, revcomp, GetSeqAlign, GetSeqAlignPiece);
10001
9835
}
10002
9836
 
10003
9837
/* This function produces a text representation of the alignment salp starting one nucleotide