| 1 |
// =========================================================================== |
| 2 |
// |
| 3 |
// PUBLIC DOMAIN NOTICE |
| 4 |
// National Center for Biotechnology Information (NCBI) |
| 5 |
// |
| 6 |
// This software/database is a "United States Government Work" under the |
| 7 |
// terms of the United States Copyright Act. It was written as part of |
| 8 |
// the author's official duties as a United States Government employee and |
| 9 |
// thus cannot be copyrighted. This software/database is freely available |
| 10 |
// to the public for use. The National Library of Medicine and the U.S. |
| 11 |
// Government do not place any restriction on its use or reproduction. |
| 12 |
// We would, however, appreciate having the NCBI and the author cited in |
| 13 |
// any work or product based on this material. |
| 14 |
// |
| 15 |
// Although all reasonable efforts have been taken to ensure the accuracy |
| 16 |
// and reliability of the software and data, the NLM and the U.S. |
| 17 |
// Government do not and cannot warrant the performance or results that |
| 18 |
// may be obtained by using this software or data. The NLM and the U.S. |
| 19 |
// Government disclaim all warranties, express or implied, including |
| 20 |
// warranties of performance, merchantability or fitness for any particular |
| 21 |
// purpose. |
| 22 |
// |
| 23 |
// =========================================================================== |
| 24 |
// |
| 25 |
// File Name: insd.go |
| 26 |
// |
| 27 |
// Author: Jonathan Kans |
| 28 |
// |
| 29 |
// ========================================================================== |
| 30 |
|
| 31 |
package eutils |
| 32 |
|
| 33 |
import ( |
| 34 |
"os" |
| 35 |
"strings" |
| 36 |
) |
| 37 |
|
| 38 |
var legalFeats map[string]string |
| 39 |
var legalQuals map[string]string |
| 40 |
var legalINSDs map[string]string |
| 41 |
|
| 42 |
// INSDSEQ EXTRACTION COMMAND GENERATOR |
| 43 |
|
| 44 |
// e.g., xtract -insd complete mat_peptide "%peptide" product mol_wt peptide |
| 45 |
|
| 46 |
// ProcessINSD generates extraction commands for GenBank/RefSeq records in INSDSet format |
| 47 |
func ProcessINSD(args []string, isPipe, addDash, doIndex, makeXML bool) []string { |
| 48 |
|
| 49 |
checkAgainstVocabulary := func(str, objtype string, legal map[string]string) { |
| 50 |
|
| 51 |
if str == "" || legal == nil { |
| 52 |
return |
| 53 |
} |
| 54 |
|
| 55 |
// skip past pound, percent, or caret character at beginning of string |
| 56 |
if len(str) > 1 { |
| 57 |
switch str[0] { |
| 58 |
case '#', '%', '^': |
| 59 |
str = str[1:] |
| 60 |
default: |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
ky := strings.ToUpper(str) |
| 65 |
val, ok := legal[ky] |
| 66 |
if ok { |
| 67 |
if str == val { |
| 68 |
return |
| 69 |
} |
| 70 |
DisplayError("Incorrect capitalization of '%s' %s, change to '%s'", str, objtype, val) |
| 71 |
os.Exit(1) |
| 72 |
} |
| 73 |
|
| 74 |
DisplayError("Item '%s' is not a legal -insd %s", str, objtype) |
| 75 |
os.Exit(1) |
| 76 |
} |
| 77 |
|
| 78 |
var acc []string |
| 79 |
|
| 80 |
max := len(args) |
| 81 |
if max < 1 { |
| 82 |
DisplayError("Insufficient command-line arguments supplied to xtract -insd") |
| 83 |
os.Exit(1) |
| 84 |
} |
| 85 |
|
| 86 |
quote := "" |
| 87 |
retrn := "\n" |
| 88 |
if !isPipe { |
| 89 |
quote = "\"" |
| 90 |
retrn = "\\n" |
| 91 |
} |
| 92 |
|
| 93 |
// record accession and sequence |
| 94 |
|
| 95 |
if doIndex { |
| 96 |
acc = append(acc, "-head", quote+"<IdxDocumentSet>"+quote, "-tail", quote+"</IdxDocumentSet>"+quote) |
| 97 |
acc = append(acc, "-hd", quote+" <IdxDocument>"+retrn+quote, "-tl", quote+" </IdxDocument>"+quote) |
| 98 |
acc = append(acc, "-pattern", "INSDSeq", "-pfx", quote+" <IdxUid>"+quote, "-sfx", quote+"</IdxUid>"+retrn+quote) |
| 99 |
acc = append(acc, "-element", "INSDSeq_accession-version", "-clr", "-rst", "-tab", retrn) |
| 100 |
} else { |
| 101 |
acc = append(acc, "-pattern", "INSDSeq", "-ACCN", "INSDSeq_accession-version") |
| 102 |
acc = append(acc, "-LCUS", "INSDSeq_locus", "-SEQ", "INSDSeq_sequence") |
| 103 |
} |
| 104 |
|
| 105 |
if doIndex { |
| 106 |
acc = append(acc, "-group", "INSDSeq", "-lbl", quote+" <IdxSearchFields>"+retrn+quote) |
| 107 |
} |
| 108 |
|
| 109 |
printAccn := true |
| 110 |
|
| 111 |
// collect descriptors |
| 112 |
|
| 113 |
if strings.HasPrefix(args[0], "INSD") { |
| 114 |
|
| 115 |
if doIndex { |
| 116 |
acc = append(acc, "-clr", "-wrp", "TIAB", "-indexer") |
| 117 |
} else { |
| 118 |
acc = append(acc, "-clr", "-pfx", quote+"\\n"+quote, "-element", quote+"&ACCN"+quote) |
| 119 |
acc = append(acc, "-group", "INSDSeq", "-sep", quote+"|"+quote, "-element") |
| 120 |
printAccn = false |
| 121 |
} |
| 122 |
|
| 123 |
for { |
| 124 |
if len(args) < 1 { |
| 125 |
return acc |
| 126 |
} |
| 127 |
str := args[0] |
| 128 |
if !strings.HasPrefix(args[0], "INSD") { |
| 129 |
break |
| 130 |
} |
| 131 |
checkAgainstVocabulary(str, "element", legalINSDs) |
| 132 |
acc = append(acc, str) |
| 133 |
args = args[1:] |
| 134 |
} |
| 135 |
|
| 136 |
} else if strings.HasPrefix(strings.ToUpper(args[0]), "INSD") { |
| 137 |
|
| 138 |
// report capitalization or vocabulary failure |
| 139 |
checkAgainstVocabulary(args[0], "element", legalINSDs) |
| 140 |
|
| 141 |
// program should not get to this point, but warn and exit anyway |
| 142 |
DisplayError("Item '%s' is not a legal -insd %s", args[0], "element") |
| 143 |
os.Exit(1) |
| 144 |
} |
| 145 |
|
| 146 |
processOneFeature := func(ftargs []string) { |
| 147 |
|
| 148 |
// skip past -insd feature clause separator |
| 149 |
|
| 150 |
if ftargs[0] == "-insd" || ftargs[0] == "-insdx" { |
| 151 |
ftargs = ftargs[1:] |
| 152 |
} |
| 153 |
|
| 154 |
// collect qualifiers |
| 155 |
|
| 156 |
partial := false |
| 157 |
complete := false |
| 158 |
|
| 159 |
if ftargs[0] == "+" || ftargs[0] == "complete" { |
| 160 |
complete = true |
| 161 |
ftargs = ftargs[1:] |
| 162 |
max-- |
| 163 |
} else if ftargs[0] == "-" || ftargs[0] == "partial" { |
| 164 |
partial = true |
| 165 |
ftargs = ftargs[1:] |
| 166 |
max-- |
| 167 |
} |
| 168 |
|
| 169 |
if max < 1 { |
| 170 |
DisplayError("No feature key supplied to xtract -insd") |
| 171 |
os.Exit(1) |
| 172 |
} |
| 173 |
|
| 174 |
acc = append(acc, "-group", "INSDFeature") |
| 175 |
|
| 176 |
// limit to designated features |
| 177 |
|
| 178 |
feature := ftargs[0] |
| 179 |
|
| 180 |
fcmd := "-if" |
| 181 |
|
| 182 |
// can specify multiple features separated by plus sign (e.g., CDS+mRNA) or comma (e.g., CDS,mRNA) |
| 183 |
plus := strings.Split(feature, "+") |
| 184 |
for _, pls := range plus { |
| 185 |
comma := strings.Split(pls, ",") |
| 186 |
for _, cma := range comma { |
| 187 |
|
| 188 |
checkAgainstVocabulary(cma, "feature", legalFeats) |
| 189 |
acc = append(acc, fcmd, "INSDFeature_key", "-equals", cma) |
| 190 |
|
| 191 |
fcmd = "-or" |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
if max < 2 { |
| 196 |
// still need at least one qualifier even on legal feature |
| 197 |
DisplayError("Feature '%s' must be followed by at least one qualifier", feature) |
| 198 |
os.Exit(1) |
| 199 |
} |
| 200 |
|
| 201 |
ftargs = ftargs[1:] |
| 202 |
|
| 203 |
if complete { |
| 204 |
acc = append(acc, "-branch", "INSDFeature", "-unless", "INSDFeature_partial5", "-or", "INSDFeature_partial3") |
| 205 |
} else if partial { |
| 206 |
acc = append(acc, "-branch", "INSDFeature", "-if", "INSDFeature_partial5", "-or", "INSDFeature_partial3") |
| 207 |
} |
| 208 |
|
| 209 |
if printAccn { |
| 210 |
if doIndex { |
| 211 |
} else { |
| 212 |
acc = append(acc, "-clr", "-pfx", quote+"\\n"+quote, "-first", quote+"&ACCN,&LCUS"+quote) |
| 213 |
printAccn = false |
| 214 |
} |
| 215 |
} |
| 216 |
|
| 217 |
if makeXML { |
| 218 |
acc = append(acc, "-block", "INSDFeature", "-element", "INSDFeature_key") |
| 219 |
} |
| 220 |
|
| 221 |
for _, str := range ftargs { |
| 222 |
|
| 223 |
alt := "" |
| 224 |
|
| 225 |
if str == "mol_wt" { |
| 226 |
str = "calculated_mol_wt" |
| 227 |
} |
| 228 |
|
| 229 |
// for the source feature, INSDC has replaced the country qualifier with geo_loc_name |
| 230 |
if feature == "source" { |
| 231 |
if str == "country" { |
| 232 |
str = "geo_loc_name" |
| 233 |
alt = "country" |
| 234 |
} else if str == "geo_loc_name" { |
| 235 |
alt = "country" |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
if strings.HasPrefix(str, "INSD") { |
| 240 |
|
| 241 |
checkAgainstVocabulary(str, "element", legalINSDs) |
| 242 |
if doIndex { |
| 243 |
acc = append(acc, "-block", "INSDFeature", "-clr", "-wrp", "TIAB", "-indexer") |
| 244 |
} else { |
| 245 |
acc = append(acc, "-block", "INSDFeature", "-sep", quote+"|"+quote, "-element") |
| 246 |
} |
| 247 |
acc = append(acc, str) |
| 248 |
if addDash { |
| 249 |
acc = append(acc, "-block", "INSDFeature", "-unless", str) |
| 250 |
if strings.HasSuffix(str, "@value") { |
| 251 |
acc = append(acc, "-lbl", quote+"false"+quote) |
| 252 |
} else { |
| 253 |
acc = append(acc, "-lbl", quote+"\\-"+quote) |
| 254 |
} |
| 255 |
} |
| 256 |
|
| 257 |
} else if strings.HasPrefix(str, "#INSD") { |
| 258 |
|
| 259 |
checkAgainstVocabulary(str, "element", legalINSDs) |
| 260 |
if doIndex { |
| 261 |
acc = append(acc, "-block", "INSDFeature", "-clr", "-wrp", "TIAB", "-indexer") |
| 262 |
} else { |
| 263 |
acc = append(acc, "-block", "INSDFeature", "-sep", quote+"|"+quote, "-element") |
| 264 |
acc = append(acc, quote+str+quote) |
| 265 |
} |
| 266 |
|
| 267 |
} else if strings.HasPrefix(strings.ToUpper(str), "#INSD") { |
| 268 |
|
| 269 |
// report capitalization or vocabulary failure |
| 270 |
checkAgainstVocabulary(str, "element", legalINSDs) |
| 271 |
|
| 272 |
} else if str == "sub_sequence" { |
| 273 |
|
| 274 |
// special sub_sequence qualifier shows sequence under feature intervals |
| 275 |
acc = append(acc, "-block", "INSDFeature_intervals") |
| 276 |
|
| 277 |
acc = append(acc, "-subset", "INSDInterval", "-FR", "INSDInterval_from", "-TO", "INSDInterval_to") |
| 278 |
acc = append(acc, "-pfx", quote+""+quote, "-tab", quote+""+quote, "-nucleic", quote+"&SEQ[&FR:&TO]"+quote) |
| 279 |
|
| 280 |
acc = append(acc, "-subset", "INSDFeature_intervals", "-deq", quote+"\\t"+quote) |
| 281 |
|
| 282 |
} else if str == "feat_location" { |
| 283 |
|
| 284 |
// special feat_location qualifier shows feature intervals, in 1-based GenBank convention |
| 285 |
acc = append(acc, "-block", "INSDFeature_intervals") |
| 286 |
|
| 287 |
acc = append(acc, "-subset", "INSDInterval", "-FR", "INSDInterval_from", "-TO", "INSDInterval_to") |
| 288 |
acc = append(acc, "-pfx", quote+""+quote, "-tab", quote+".."+quote, "-element", quote+"&FR"+quote) |
| 289 |
acc = append(acc, "-pfx", quote+""+quote, "-tab", quote+","+quote, "-element", quote+"&TO"+quote) |
| 290 |
|
| 291 |
acc = append(acc, "-subset", "INSDFeature_intervals", "-deq", quote+"\\t"+quote) |
| 292 |
|
| 293 |
} else if str == "feat_intervals" { |
| 294 |
|
| 295 |
// special feat_intervals qualifier shows feature intervals, decremented to 0-based |
| 296 |
acc = append(acc, "-block", "INSDFeature_intervals") |
| 297 |
|
| 298 |
acc = append(acc, "-subset", "INSDInterval") |
| 299 |
acc = append(acc, "-pfx", quote+""+quote, "-tab", quote+".."+quote, "-dec", "INSDInterval_from") |
| 300 |
acc = append(acc, "-pfx", quote+""+quote, "-tab", quote+","+quote, "-dec", "INSDInterval_to") |
| 301 |
|
| 302 |
acc = append(acc, "-subset", "INSDFeature_intervals", "-deq", quote+"\\t"+quote) |
| 303 |
|
| 304 |
} else if str == "chloroplast" || |
| 305 |
str == "chromoplast" || |
| 306 |
str == "cyanelle" || |
| 307 |
str == "environmental_sample" || |
| 308 |
str == "focus" || |
| 309 |
str == "germline" || |
| 310 |
str == "kinetoplast" || |
| 311 |
str == "macronuclear" || |
| 312 |
str == "metagenomic" || |
| 313 |
str == "mitochondrion" || |
| 314 |
str == "partial" || |
| 315 |
str == "proviral" || |
| 316 |
str == "pseudo" || |
| 317 |
str == "rearranged" || |
| 318 |
str == "ribosomal_slippage" || |
| 319 |
str == "trans_splicing" || |
| 320 |
str == "transgenic" || |
| 321 |
str == "virion" { |
| 322 |
|
| 323 |
acc = append(acc, "-block", "INSDQualifier") |
| 324 |
|
| 325 |
checkAgainstVocabulary(str, "qualifier", legalQuals) |
| 326 |
if doIndex { |
| 327 |
acc = append(acc, "-if", "INSDQualifier_name", "-equals", str) |
| 328 |
acc = append(acc, "-clr", "-wrp", "TIAB", "-indexer", "INSDQualifier_name") |
| 329 |
} else { |
| 330 |
acc = append(acc, "-if", "INSDQualifier_name", "-equals", str) |
| 331 |
acc = append(acc, "-lbl", str) |
| 332 |
} |
| 333 |
if addDash { |
| 334 |
acc = append(acc, "-block", "INSDFeature", "-unless", "INSDQualifier_name", "-equals", str) |
| 335 |
acc = append(acc, "-lbl", quote+"\\-"+quote) |
| 336 |
} |
| 337 |
|
| 338 |
} else { |
| 339 |
|
| 340 |
acc = append(acc, "-block", "INSDQualifier") |
| 341 |
|
| 342 |
isTaxID := false |
| 343 |
if feature == "source" && (str == "taxon" || str == "taxid") { |
| 344 |
// special taxid qualifier extracts number from taxon db_xref |
| 345 |
isTaxID = true |
| 346 |
str = "db_xref" |
| 347 |
} else { |
| 348 |
checkAgainstVocabulary(str, "qualifier", legalQuals) |
| 349 |
} |
| 350 |
|
| 351 |
if len(str) > 2 && str[0] == '%' { |
| 352 |
acc = append(acc, "-if", "INSDQualifier_name", "-equals", str[1:]) |
| 353 |
if doIndex { |
| 354 |
acc = append(acc, "-clr", "-wrp", "TIAB", "-indexer", quote+"%INSDQualifier_value"+quote) |
| 355 |
} else { |
| 356 |
acc = append(acc, "-element", quote+"%INSDQualifier_value"+quote) |
| 357 |
} |
| 358 |
if addDash { |
| 359 |
acc = append(acc, "-block", "INSDFeature", "-unless", "INSDQualifier_name", "-equals", str[1:]) |
| 360 |
acc = append(acc, "-lbl", quote+"\\-"+quote) |
| 361 |
} |
| 362 |
} else { |
| 363 |
if doIndex { |
| 364 |
acc = append(acc, "-if", "INSDQualifier_name", "-equals", str) |
| 365 |
acc = append(acc, "-clr", "-wrp", "TIAB", "-indexer", "INSDQualifier_value") |
| 366 |
} else if isTaxID { |
| 367 |
acc = append(acc, "-if", "INSDQualifier_name", "-equals", str) |
| 368 |
acc = append(acc, "-and", "INSDQualifier_value", "-starts-with", "taxon:") |
| 369 |
acc = append(acc, "-element", "INSDQualifier_value[taxon:|]") |
| 370 |
} else { |
| 371 |
acc = append(acc, "-if", "INSDQualifier_name", "-equals", str) |
| 372 |
if alt != "" { |
| 373 |
acc = append(acc, "-or", "INSDQualifier_name", "-equals", alt) |
| 374 |
} |
| 375 |
acc = append(acc, "-element", "INSDQualifier_value") |
| 376 |
} |
| 377 |
if addDash { |
| 378 |
if isTaxID { |
| 379 |
acc = append(acc, "-block", "INSDFeature", "-unless", "INSDQualifier_value", "-starts-with", "taxon:") |
| 380 |
} else { |
| 381 |
acc = append(acc, "-block", "INSDFeature", "-unless", "INSDQualifier_name", "-equals", str) |
| 382 |
} |
| 383 |
acc = append(acc, "-lbl", quote+"\\-"+quote) |
| 384 |
} |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
|
| 390 |
// multiple feature clauses are separated by additional -insd arguments |
| 391 |
|
| 392 |
last := 0 |
| 393 |
curr := 0 |
| 394 |
nxt := "" |
| 395 |
|
| 396 |
for curr, nxt = range args { |
| 397 |
if nxt == "-insd" || nxt == "-insdx" { |
| 398 |
if last < curr { |
| 399 |
processOneFeature(args[last:curr]) |
| 400 |
last = curr |
| 401 |
} |
| 402 |
} |
| 403 |
} |
| 404 |
|
| 405 |
if last < curr { |
| 406 |
processOneFeature(args[last:]) |
| 407 |
} |
| 408 |
|
| 409 |
if doIndex { |
| 410 |
acc = append(acc, "-group", "INSDSeq", "-clr", "-lbl", quote+" </IdxSearchFields>"+retrn+quote) |
| 411 |
} |
| 412 |
|
| 413 |
return acc |
| 414 |
} |
| 415 |
|
| 416 |
// BIOTHINGS EXTRACTION COMMAND GENERATOR |
| 417 |
|
| 418 |
// ProcessBiopath generates extraction commands for BioThings resources (undocumented) |
| 419 |
func ProcessBiopath(args []string, isPipe bool) []string { |
| 420 |
|
| 421 |
// nquire -get "http://myvariant.info/v1/variant/chr6:g.26093141G>A" \ |
| 422 |
// -fields clinvar.rcv.conditions.identifiers \ |
| 423 |
// -always_list clinvar.rcv.conditions.identifiers | |
| 424 |
// transmute -j2x | |
| 425 |
// xtract -biopath opt clinvar.rcv.conditions.identifiers.omim |
| 426 |
|
| 427 |
var acc []string |
| 428 |
|
| 429 |
max := len(args) |
| 430 |
if max < 2 { |
| 431 |
DisplayError("Insufficient command-line arguments supplied to xtract -biopath") |
| 432 |
os.Exit(1) |
| 433 |
} |
| 434 |
|
| 435 |
obj := args[0] |
| 436 |
args = args[1:] |
| 437 |
|
| 438 |
acc = append(acc, "-pattern", obj) |
| 439 |
|
| 440 |
paths := args[0] |
| 441 |
|
| 442 |
items := strings.Split(paths, ",") |
| 443 |
|
| 444 |
for _, path := range items { |
| 445 |
|
| 446 |
dirs := strings.Split(path, ".") |
| 447 |
max = len(dirs) |
| 448 |
if max < 1 { |
| 449 |
DisplayError("Insufficient path arguments supplied to xtract -biopath") |
| 450 |
os.Exit(1) |
| 451 |
} |
| 452 |
if max > 7 { |
| 453 |
DisplayError("Too many nodes in argument supplied to xtract -biopath") |
| 454 |
os.Exit(1) |
| 455 |
} |
| 456 |
|
| 457 |
str := dirs[max-1] |
| 458 |
|
| 459 |
acc = append(acc, "-path") |
| 460 |
if isPipe { |
| 461 |
acc = append(acc, path) |
| 462 |
acc = append(acc, "-tab", "\\n") |
| 463 |
acc = append(acc, "-element", str) |
| 464 |
} else { |
| 465 |
acc = append(acc, "\""+path+"\"") |
| 466 |
acc = append(acc, "-tab", "\"\\n\"") |
| 467 |
acc = append(acc, "-element", "\""+str+"\"") |
| 468 |
} |
| 469 |
} |
| 470 |
|
| 471 |
return acc |
| 472 |
} |
| 473 |
|
| 474 |
func init() { |
| 475 |
|
| 476 |
// legal GenBank / GenPept / RefSeq features |
| 477 |
feats := []string{ |
| 478 |
"-10_signal", |
| 479 |
"-35_signal", |
| 480 |
"3'clip", |
| 481 |
"3'UTR", |
| 482 |
"5'clip", |
| 483 |
"5'UTR", |
| 484 |
"allele", |
| 485 |
"assembly_gap", |
| 486 |
"attenuator", |
| 487 |
"Bond", |
| 488 |
"C_region", |
| 489 |
"CAAT_signal", |
| 490 |
"CDS", |
| 491 |
"centromere", |
| 492 |
"conflict", |
| 493 |
"D_segment", |
| 494 |
"D-loop", |
| 495 |
"enhancer", |
| 496 |
"exon", |
| 497 |
"gap", |
| 498 |
"GC_signal", |
| 499 |
"gene", |
| 500 |
"iDNA", |
| 501 |
"intron", |
| 502 |
"J_segment", |
| 503 |
"LTR", |
| 504 |
"mat_peptide", |
| 505 |
"misc_binding", |
| 506 |
"misc_difference", |
| 507 |
"misc_feature", |
| 508 |
"misc_recomb", |
| 509 |
"misc_RNA", |
| 510 |
"misc_signal", |
| 511 |
"misc_structure", |
| 512 |
"mobile_element", |
| 513 |
"modified_base", |
| 514 |
"mRNA", |
| 515 |
"mutation", |
| 516 |
"N_region", |
| 517 |
"ncRNA", |
| 518 |
"old_sequence", |
| 519 |
"operon", |
| 520 |
"oriT", |
| 521 |
"polyA_signal", |
| 522 |
"polyA_site", |
| 523 |
"precursor_RNA", |
| 524 |
"prim_transcript", |
| 525 |
"primer_bind", |
| 526 |
"promoter", |
| 527 |
"proprotein", |
| 528 |
"protein_bind", |
| 529 |
"Protein", |
| 530 |
"RBS", |
| 531 |
"Region", |
| 532 |
"regulatory", |
| 533 |
"rep_origin", |
| 534 |
"repeat_region", |
| 535 |
"repeat_unit", |
| 536 |
"rRNA", |
| 537 |
"S_region", |
| 538 |
"satellite", |
| 539 |
"scRNA", |
| 540 |
"sig_peptide", |
| 541 |
"Site", |
| 542 |
"snoRNA", |
| 543 |
"snRNA", |
| 544 |
"source", |
| 545 |
"stem_loop", |
| 546 |
"STS", |
| 547 |
"TATA_signal", |
| 548 |
"telomere", |
| 549 |
"terminator", |
| 550 |
"tmRNA", |
| 551 |
"transit_peptide", |
| 552 |
"tRNA", |
| 553 |
"unsure", |
| 554 |
"V_region", |
| 555 |
"V_segment", |
| 556 |
"variation", |
| 557 |
} |
| 558 |
|
| 559 |
// legal GenBank / GenPept / RefSeq qualifiers |
| 560 |
quals := []string{ |
| 561 |
"allele", |
| 562 |
"altitude", |
| 563 |
"anticodon", |
| 564 |
"artificial_location", |
| 565 |
"bio_material", |
| 566 |
"bond_type", |
| 567 |
"bound_moiety", |
| 568 |
"breed", |
| 569 |
"calculated_mol_wt", |
| 570 |
"cell_line", |
| 571 |
"cell_type", |
| 572 |
"chloroplast", |
| 573 |
"chromoplast", |
| 574 |
"chromosome", |
| 575 |
"circular_RNA", |
| 576 |
"citation", |
| 577 |
"clone_lib", |
| 578 |
"clone", |
| 579 |
"coded_by", |
| 580 |
"codon_start", |
| 581 |
"codon", |
| 582 |
"collected_by", |
| 583 |
"collection_date", |
| 584 |
"compare", |
| 585 |
"cons_splice", |
| 586 |
"country", |
| 587 |
"cultivar", |
| 588 |
"culture_collection", |
| 589 |
"cyanelle", |
| 590 |
"db_xref", |
| 591 |
"derived_from", |
| 592 |
"dev_stage", |
| 593 |
"direction", |
| 594 |
"EC_number", |
| 595 |
"ecotype", |
| 596 |
"encodes", |
| 597 |
"endogenous_virus", |
| 598 |
"environmental_sample", |
| 599 |
"estimated_length", |
| 600 |
"evidence", |
| 601 |
"exception", |
| 602 |
"experiment", |
| 603 |
"focus", |
| 604 |
"frequency", |
| 605 |
"function", |
| 606 |
"gap_type", |
| 607 |
"gdb_xref", |
| 608 |
"gene_synonym", |
| 609 |
"gene", |
| 610 |
"geo_loc_name", |
| 611 |
"germline", |
| 612 |
"GO_component", |
| 613 |
"GO_function", |
| 614 |
"GO_process", |
| 615 |
"haplogroup", |
| 616 |
"haplotype", |
| 617 |
"host", |
| 618 |
"identified_by", |
| 619 |
"inference", |
| 620 |
"insertion_seq", |
| 621 |
"isolate", |
| 622 |
"isolation_source", |
| 623 |
"kinetoplast", |
| 624 |
"lab_host", |
| 625 |
"label", |
| 626 |
"lat_lon", |
| 627 |
"linkage_evidence", |
| 628 |
"locus_tag", |
| 629 |
"macronuclear", |
| 630 |
"map", |
| 631 |
"mating_type", |
| 632 |
"metagenome_source", |
| 633 |
"metagenomic", |
| 634 |
"mitochondrion", |
| 635 |
"mobile_element_type", |
| 636 |
"mobile_element", |
| 637 |
"mod_base", |
| 638 |
"mol_type", |
| 639 |
"name", |
| 640 |
"nat_host", |
| 641 |
"ncRNA_class", |
| 642 |
"non_functional", |
| 643 |
"note", |
| 644 |
"number", |
| 645 |
"old_locus_tag", |
| 646 |
"operon", |
| 647 |
"organelle", |
| 648 |
"organism", |
| 649 |
"partial", |
| 650 |
"PCR_conditions", |
| 651 |
"PCR_primers", |
| 652 |
"peptide", |
| 653 |
"phenotype", |
| 654 |
"plasmid", |
| 655 |
"pop_variant", |
| 656 |
"product", |
| 657 |
"protein_id", |
| 658 |
"proviral", |
| 659 |
"pseudo", |
| 660 |
"pseudogene", |
| 661 |
"rearranged", |
| 662 |
"recombination_class", |
| 663 |
"region_name", |
| 664 |
"regulatory_class", |
| 665 |
"replace", |
| 666 |
"ribosomal_slippage", |
| 667 |
"rpt_family", |
| 668 |
"rpt_type", |
| 669 |
"rpt_unit_range", |
| 670 |
"rpt_unit_seq", |
| 671 |
"rpt_unit", |
| 672 |
"satellite", |
| 673 |
"segment", |
| 674 |
"sequenced_mol", |
| 675 |
"serotype", |
| 676 |
"serovar", |
| 677 |
"sex", |
| 678 |
"site_type", |
| 679 |
"specific_host", |
| 680 |
"specimen_voucher", |
| 681 |
"standard_name", |
| 682 |
"strain", |
| 683 |
"structural_class", |
| 684 |
"sub_clone", |
| 685 |
"sub_species", |
| 686 |
"sub_strain", |
| 687 |
"submitter_seqid", |
| 688 |
"tag_peptide", |
| 689 |
"tissue_lib", |
| 690 |
"tissue_type", |
| 691 |
"trans_splicing", |
| 692 |
"transcript_id", |
| 693 |
"transcription", |
| 694 |
"transgenic", |
| 695 |
"transl_except", |
| 696 |
"transl_table", |
| 697 |
"translation", |
| 698 |
"transposon", |
| 699 |
"type_material", |
| 700 |
"UniProtKB_evidence", |
| 701 |
"usedin", |
| 702 |
"variety", |
| 703 |
"virion", |
| 704 |
} |
| 705 |
|
| 706 |
// legal INSDSeq XML fields |
| 707 |
|
| 708 |
insds := []string{ |
| 709 |
"INSDAltSeqData_items", |
| 710 |
"INSDAltSeqData", |
| 711 |
"INSDAltSeqItem_first-accn", |
| 712 |
"INSDAltSeqItem_gap-comment", |
| 713 |
"INSDAltSeqItem_gap-length", |
| 714 |
"INSDAltSeqItem_gap-linkage", |
| 715 |
"INSDAltSeqItem_gap-type", |
| 716 |
"INSDAltSeqItem_interval", |
| 717 |
"INSDAltSeqItem_isgap", |
| 718 |
"INSDAltSeqItem_isgap@value", |
| 719 |
"INSDAltSeqItem_last-accn", |
| 720 |
"INSDAltSeqItem_value", |
| 721 |
"INSDAltSeqItem", |
| 722 |
"INSDAuthor", |
| 723 |
"INSDComment_paragraphs", |
| 724 |
"INSDComment_type", |
| 725 |
"INSDComment", |
| 726 |
"INSDCommentParagraph", |
| 727 |
"INSDFeature_intervals", |
| 728 |
"INSDFeature_key", |
| 729 |
"INSDFeature_location", |
| 730 |
"INSDFeature_operator", |
| 731 |
"INSDFeature_partial3", |
| 732 |
"INSDFeature_partial3@value", |
| 733 |
"INSDFeature_partial5", |
| 734 |
"INSDFeature_partial5@value", |
| 735 |
"INSDFeature_quals", |
| 736 |
"INSDFeature_xrefs", |
| 737 |
"INSDFeature", |
| 738 |
"INSDFeatureSet_annot-source", |
| 739 |
"INSDFeatureSet_features", |
| 740 |
"INSDFeatureSet", |
| 741 |
"INSDInterval_accession", |
| 742 |
"INSDInterval_from", |
| 743 |
"INSDInterval_interbp", |
| 744 |
"INSDInterval_interbp@value", |
| 745 |
"INSDInterval_iscomp", |
| 746 |
"INSDInterval_iscomp@value", |
| 747 |
"INSDInterval_point", |
| 748 |
"INSDInterval_to", |
| 749 |
"INSDInterval", |
| 750 |
"INSDKeyword", |
| 751 |
"INSDQualifier_name", |
| 752 |
"INSDQualifier_value", |
| 753 |
"INSDQualifier", |
| 754 |
"INSDReference_authors", |
| 755 |
"INSDReference_consortium", |
| 756 |
"INSDReference_journal", |
| 757 |
"INSDReference_position", |
| 758 |
"INSDReference_pubmed", |
| 759 |
"INSDReference_reference", |
| 760 |
"INSDReference_remark", |
| 761 |
"INSDReference_title", |
| 762 |
"INSDReference_xref", |
| 763 |
"INSDReference", |
| 764 |
"INSDSecondary-accn", |
| 765 |
"INSDSeq_accession-version", |
| 766 |
"INSDSeq_alt-seq", |
| 767 |
"INSDSeq_comment-set", |
| 768 |
"INSDSeq_comment", |
| 769 |
"INSDSeq_contig", |
| 770 |
"INSDSeq_create-date", |
| 771 |
"INSDSeq_create-release", |
| 772 |
"INSDSeq_database-reference", |
| 773 |
"INSDSeq_definition", |
| 774 |
"INSDSeq_division", |
| 775 |
"INSDSeq_entry-version", |
| 776 |
"INSDSeq_feature-set", |
| 777 |
"INSDSeq_feature-table", |
| 778 |
"INSDSeq_keywords", |
| 779 |
"INSDSeq_length", |
| 780 |
"INSDSeq_locus", |
| 781 |
"INSDSeq_moltype", |
| 782 |
"INSDSeq_organism", |
| 783 |
"INSDSeq_other-seqids", |
| 784 |
"INSDSeq_primary-accession", |
| 785 |
"INSDSeq_primary", |
| 786 |
"INSDSeq_project", |
| 787 |
"INSDSeq_references", |
| 788 |
"INSDSeq_secondary-accessions", |
| 789 |
"INSDSeq_segment", |
| 790 |
"INSDSeq_sequence", |
| 791 |
"INSDSeq_source-db", |
| 792 |
"INSDSeq_source", |
| 793 |
"INSDSeq_strandedness", |
| 794 |
"INSDSeq_struc-comments", |
| 795 |
"INSDSeq_taxonomy", |
| 796 |
"INSDSeq_topology", |
| 797 |
"INSDSeq_update-date", |
| 798 |
"INSDSeq_update-release", |
| 799 |
"INSDSeq_xrefs", |
| 800 |
"INSDSeq", |
| 801 |
"INSDSeqid", |
| 802 |
"INSDSet", |
| 803 |
"INSDStrucComment_items", |
| 804 |
"INSDStrucComment_name", |
| 805 |
"INSDStrucComment", |
| 806 |
"INSDStrucCommentItem_tag", |
| 807 |
"INSDStrucCommentItem_url", |
| 808 |
"INSDStrucCommentItem_value", |
| 809 |
"INSDStrucCommentItem", |
| 810 |
"INSDXref_dbname", |
| 811 |
"INSDXref_id", |
| 812 |
"INSDXref", |
| 813 |
} |
| 814 |
|
| 815 |
legalFeats = make(map[string]string) |
| 816 |
legalQuals = make(map[string]string) |
| 817 |
legalINSDs = make(map[string]string) |
| 818 |
|
| 819 |
for _, str := range feats { |
| 820 |
ky := strings.ToUpper(str) |
| 821 |
legalFeats[ky] = str |
| 822 |
} |
| 823 |
|
| 824 |
for _, str := range quals { |
| 825 |
ky := strings.ToUpper(str) |
| 826 |
legalQuals[ky] = str |
| 827 |
} |
| 828 |
for _, str := range insds { |
| 829 |
ky := strings.ToUpper(str) |
| 830 |
legalINSDs[ky] = str |
| 831 |
} |
| 832 |
} |