669
/* launch tRNAscan-SE with -q parameter and name of data file */
680
/* launch tRNAscan-SE with -q parameter and name of data file */
671
682
speed = FindByName ("speed");
672
if (speed != NULL && strcmp (speed, "slow") == 0) {
673
sprintf (cmmd, "./tRNAscan-SE -q -C %s", tempfile);
675
sprintf (cmmd, "./tRNAscan-SE -q %s", tempfile);
683
domain = FindByName ("domain");
684
extras = FindByName ("extras");
687
if (strcmp (speed, "slow") == 0) {
692
if (domain != NULL) {
693
if (strcmp (domain, "eukaryote") == 0) {
695
} else if (strcmp (domain, "prokaryote") == 0) {
697
} else if (strcmp (domain, "archaea") == 0) {
699
} else if (strcmp (domain, "organelle") == 0) {
701
} else if (strcmp (domain, "general") == 0) {
706
sprintf (cmmd, "./tRNAscan-SE -q %s%s%s", arg1, arg2, tempfile);
678
708
fp = popen (cmmd, "r");
679
709
if (fp == NULL) return;
681
/* line by line processing of tRNAscan-SE output table */
711
/* line by line processing of tRNAscan-SE output table */
683
713
while (fgets (buf, sizeof (buf), fp) != NULL) {
685
715
if (! headerSent) {
687
/* send required first header information to stdout */
717
/* send required first header information to stdout */
689
719
printf ("Content-type: text/html\r\n\r\n");
834
static CharPtr IsolateString (CharPtr str, Char ch)
839
if (str == NULL || ch == '\0') return NULL;
840
ptr = strchr (str, ch);
848
static Bool ParseRange (CharPtr str, Int4Ptr startP, Int4Ptr stopP)
856
if (str == NULL || startP == NULL || stopP == NULL) return FALSE;
860
nxt = IsolateString (str, '(');
861
if (nxt == NULL) return FALSE;
864
nxt = IsolateString (ptr, '-');
865
if (nxt == NULL) return FALSE;
867
if (sscanf (ptr, "%ld", &start) != 1) return FALSE;
870
nxt = IsolateString (ptr, ')');
871
if (nxt == NULL) return FALSE;
873
if (sscanf (ptr, "%ld", &stop) != 1) return FALSE;
881
static void RunTrnaScan (CharPtr tempfile)
885
long int anticodonStart;
886
long int anticodonStop;
898
Int2 idNotSent = TRUE;
901
long int intronStart;
911
/* launch tRNAscan-SE with -q parameter and name of data file */
913
speed = FindByName ("speed");
914
domain = FindByName ("domain");
915
gencode = FindByName ("gencode");
918
if (strcmp (speed, "slow") == 0) {
923
if (domain != NULL) {
924
if (strcmp (domain, "eukaryote") == 0) {
926
} else if (strcmp (domain, "prokaryote") == 0) {
928
} else if (strcmp (domain, "archaea") == 0) {
930
} else if (strcmp (domain, "organelle") == 0) {
932
} else if (strcmp (domain, "general") == 0) {
937
if (gencode != NULL) {
938
if (strcmp (gencode, "standard") == 0) {
940
} else if (strcmp (gencode, "vertebrate") == 0) {
941
arg3 = "-g gcode.vertmito ";
942
} else if (strcmp (gencode, "yeast") == 0) {
943
arg3 = "-g gcode.ystmito ";
944
} else if (strcmp (gencode, "mold") == 0) {
945
arg3 = "-g gcode.othmito ";
946
} else if (strcmp (gencode, "invertebrate") == 0) {
947
arg3 = "-g gcode.invmito ";
948
} else if (strcmp (gencode, "echinoderm") == 0) {
949
arg3 = "-g gcode.echdmito ";
950
} else if (strcmp (gencode, "ciliate") == 0) {
951
arg3 = "-g gcode.cilnuc ";
955
sprintf (cmmd, "./tRNAscan-SE -q -f $ %s%s%s%s", arg1, arg2, arg3, tempfile);
957
fp = popen (cmmd, "r");
958
if (fp == NULL) return;
960
/* send required first header information to stdout */
962
printf ("Content-type: text/html\r\n\r\n");
965
/* initialize variables */
977
/* line by line processing of tRNAscan-SE output table */
979
while (fgets (buf, sizeof (buf), fp) != NULL) {
984
} else if (strncmp (buf, "Str:", 4) == 0) {
986
} else if (strncmp (buf, "Seq:", 4) == 0) {
988
/* first line of output gives SeqId from FASTA definition line */
991
sprintf (str, ">Features %s tRNAscan-SE\n", id);
992
EncodeAndWrite (str, strlen (str), stdout);
997
/* first line of feature has start (tab) stop (tab) feature key */
998
/* multiple intervals would have lines of start (tab) stop */
1000
if (intronStart == 0 && intronStop == 0) {
1001
sprintf (str, "%ld\t%ld\ttRNA\n", (long) start, (long) stop);
1002
EncodeAndWrite (str, strlen (str), stdout);
1005
sprintf (str, "%ld\t%ld\ttRNA\n", (long) start, (long) (intronStart - 1));
1006
EncodeAndWrite (str, strlen (str), stdout);
1008
sprintf (str, "%ld\t%ld\n", (long) (intronStop + 1), (long) stop);
1009
EncodeAndWrite (str, strlen (str), stdout);
1013
/* qualifier lines are (tab) (tab) (tab) qualifier key (tab) value */
1015
sprintf (str, "\t\t\tproduct\t%s\n", aa);
1016
EncodeAndWrite (str, strlen (str), stdout);
1020
sprintf (str, "\t\t\tpseudo\n");
1021
EncodeAndWrite (str, strlen (str), stdout);
1023
} else if (anticodonStart != 0 && anticodonStop != 0) {
1024
if (anticodonStart < anticodonStop) {
1025
sprintf (str, "\t\t\tanticodon\t(pos:%ld..%ld,aa:%s)\n",
1026
(long) anticodonStart, (long) anticodonStop, aa);
1027
EncodeAndWrite (str, strlen (str), stdout);
1030
sprintf (str, "\t\t\tanticodon\t(pos:complement(%ld..%ld),aa:%s)\n",
1031
(long) anticodonStop, (long) anticodonStart, aa);
1032
EncodeAndWrite (str, strlen (str), stdout);
1037
/* dash (formerly empty) gene qualifier to suppress /gene (e.g., if tRNA is in an intron) */
1039
sprintf (str, "\t\t\tgene\t-\n");
1040
EncodeAndWrite (str, strlen (str), stdout);
1043
/* reset variables */
1055
} else if (strncmp (buf, "Type:", 5) == 0) {
1057
nxt = IsolateString (buf, ' ');
1060
nxt = IsolateString (ptr, '\t');
1063
if (strcmp (aa, "Undet") == 0 || strcmp (aa, "Sup") == 0) {
1064
strcpy (aa, "OTHER");
1067
ParseRange (ptr, &anticodonStart, &anticodonStop);
1071
} else if (strncmp (buf, "Possible intron:", 16) == 0) {
1073
ParseRange (ptr, &intronStart, &intronStop);
1075
} else if (strncmp (buf, "Possible pseudogene:", 20) == 0) {
1079
} else if (strstr (buf, "Length:") != NULL) {
1081
ptr = strstr (buf, ".trna");
1087
ParseRange (ptr, &start, &stop);
1095
sprintf (str, ">Message\ntRNAscan-SE found no tRNA genes in this sequence\n");
1096
EncodeAndWrite (str, strlen (str), stdout);
794
1102
/* this program can provide several services, specified in URL query string */