Method: Bio::FlatFile::AutoDetect.make_default

Defined in:
lib/bio/io/flatfile/autodetection.rb

.make_defaultObject

make a default of default autodetect object



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/bio/io/flatfile/autodetection.rb', line 368

def self.make_default
  a = self[
    genbank  = RuleRegexp[ 'Bio::GenBank',
      /^LOCUS       .+ bp .*[a-z]*[DR]?NA/ ],
    genpept  = RuleRegexp[ 'Bio::GenPept',
      /^LOCUS       .+ aa .+/ ],
    medline  = RuleRegexp[ 'Bio::MEDLINE',
      /^PMID\- [0-9]+$/ ],
    embl     = RuleRegexp[ 'Bio::EMBL',
      /^ID   .+\; .*(DNA|RNA|XXX)\;/ ],
    sptr     = RuleRegexp2[ 'Bio::SPTR',
      /^ID   .+\; *PRT\;/,
      /^ID   [-A-Za-z0-9_\.]+ .+\; *[0-9]+ *AA\./ ],
    prosite  = RuleRegexp[ 'Bio::PROSITE',
      /^ID   [-A-Za-z0-9_\.]+\; (PATTERN|RULE|MATRIX)\.$/ ],
    transfac = RuleRegexp[ 'Bio::TRANSFAC',
      /^AC  [-A-Za-z0-9_\.]+$/ ],

    aaindex  = RuleProc.new('Bio::AAindex1', 'Bio::AAindex2') do |text|
      if /^H [-A-Z0-9_\.]+$/ =~ text then
        if text =~ /^M [rc]/ then
          Bio::AAindex2
        elsif text =~ /^I    A\/L/ then
          Bio::AAindex1
        else
          false #fail to determine
        end
      else
        nil
      end
    end,

    litdb    = RuleRegexp[ 'Bio::LITDB',
      /^CODE        [0-9]+$/ ],
    brite    = RuleRegexp[ 'Bio::KEGG::BRITE',
      /^Entry           [A-Z0-9]+/ ],
    orthology = RuleRegexp[ 'Bio::KEGG::ORTHOLOGY',
      /^ENTRY       .+ KO\s*/ ],
    drug     = RuleRegexp[ 'Bio::KEGG::DRUG',
      /^ENTRY       .+ Drug\s*/ ],
    glycan   = RuleRegexp[ 'Bio::KEGG::GLYCAN',
      /^ENTRY       .+ Glycan\s*/ ],
    enzyme   = RuleRegexp2[ 'Bio::KEGG::ENZYME',
      /^ENTRY       EC [0-9\.]+$/,
      /^ENTRY       .+ Enzyme\s*/
    ],
    compound = RuleRegexp2[ 'Bio::KEGG::COMPOUND',
      /^ENTRY       C[A-Za-z0-9\._]+$/,
      /^ENTRY       .+ Compound\s*/
    ],
    reaction = RuleRegexp2[ 'Bio::KEGG::REACTION',
      /^ENTRY       R[A-Za-z0-9\._]+$/,
      /^ENTRY       .+ Reaction\s*/
    ],
    genes    = RuleRegexp[ 'Bio::KEGG::GENES',
      /^ENTRY       .+ (CDS|gene|.*RNA|Contig) / ],
    genome   = RuleRegexp[ 'Bio::KEGG::GENOME',
      /^ENTRY       [a-z]+$/ ],

    fantom = RuleProc.new('Bio::FANTOM::MaXML::Cluster',
                          'Bio::FANTOM::MaXML::Sequence') do |text|
      if /\<\!DOCTYPE\s+maxml\-(sequences|clusters)\s+SYSTEM/ =~ text
        case $1
        when 'clusters'
          Bio::FANTOM::MaXML::Cluster
        when 'sequences'
          Bio::FANTOM::MaXML::Sequence
        else
          nil #unknown
        end
      else
        nil
      end
    end,

    pdb = RuleRegexp[ 'Bio::PDB',
      /^HEADER    .{40}\d\d\-[A-Z]{3}\-\d\d   [0-9A-Z]{4}/ ],
    het = RuleRegexp[ 'Bio::PDB::ChemicalComponent',
      /^RESIDUE +.+ +\d+\s*$/ ],

    clustal = RuleRegexp2[ 'Bio::ClustalW::Report',
    /^CLUSTAL .*\(.*\).*sequence +alignment/,
    /^CLUSTAL FORMAT for T-COFFEE/ ],

    gcg_msf = RuleRegexp[ 'Bio::GCG::Msf',
    /^!!(N|A)A_MULTIPLE_ALIGNMENT .+/ ],

    gcg_seq = RuleRegexp[ 'Bio::GCG::Seq',
    /^!!(N|A)A_SEQUENCE .+/ ],

    blastxml = RuleRegexp[ 'Bio::Blast::Report',
      /\<\!DOCTYPE BlastOutput PUBLIC / ],
    wublast  = RuleRegexp[ 'Bio::Blast::WU::Report',
      /^BLAST.? +[\-\.\w]+\-WashU +\[[\-\.\w ]+\]/ ],
    wutblast = RuleRegexp[ 'Bio::Blast::WU::Report_TBlast',
      /^TBLAST.? +[\-\.\w]+\-WashU +\[[\-\.\w ]+\]/ ],
    blast    = RuleRegexp[ 'Bio::Blast::Default::Report',
      /^BLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ],
    tblast   = RuleRegexp[ 'Bio::Blast::Default::Report_TBlast',
      /^TBLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ],
    rpsblast   = RuleRegexp[ 'Bio::Blast::RPSBlast::Report',
      /^RPS\-BLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ],

    blat   = RuleRegexp[ 'Bio::Blat::Report',
      /^psLayout version \d+/ ],
    spidey = RuleRegexp[ 'Bio::Spidey::Report',
      /^\-\-SPIDEY version .+\-\-$/ ],
    hmmer  = RuleRegexp[ 'Bio::HMMER::Report',
      /^HMMER +\d+\./ ],
    sim4   = RuleRegexp[ 'Bio::Sim4::Report',
      /^seq1 \= .*\, \d+ bp(\r|\r?\n)seq2 \= .*\, \d+ bp(\r|\r?\n)/ ],

    fastaformat = RuleProc.new('Bio::FastaFormat',
                               'Bio::NBRF',
                               'Bio::FastaNumericFormat') do |text|
      if /^>.+$/ =~ text
        case text
        when /^>([PF]1|[DR][LC]|N[13]|XX)\;.+/
          Bio::NBRF
        when /^>.+$\s+(^\#.*$\s*)*^\s*\d*\s*[-a-zA-Z_\.\[\]\(\)\*\+\$]+/
            Bio::FastaFormat
        when /^>.+$\s+^\s*\d+(\s+\d+)*\s*$/
          Bio::FastaNumericFormat
        else
          false
        end
      else
        nil
      end
    end
  ]

  # dependencies
  # NCBI
  genbank.is_prior_to genpept
  # EMBL/UniProt
  embl.is_prior_to sptr
  sptr.is_prior_to prosite
  prosite.is_prior_to transfac
  # KEGG
  #aaindex.is_prior_to litdb
  #litdb.is_prior_to brite
  brite.is_prior_to orthology
  orthology.is_prior_to drug
  drug.is_prior_to glycan
  glycan.is_prior_to enzyme
  enzyme.is_prior_to compound
  compound.is_prior_to reaction
  reaction.is_prior_to genes
  genes.is_prior_to genome
  # PDB
  pdb.is_prior_to het
  # BLAST
  wublast.is_prior_to wutblast
  wutblast.is_prior_to blast
  blast.is_prior_to tblast
  # FastaFormat
  BottomRule.is_prior_to(fastaformat)

  # for debug
  #debug_first = RuleDebug.new('debug_first')
  #a.add(debug_first)
  #debug_first.is_prior_to(TopRule)

  ## for debug
  #debug_last = RuleDebug.new('debug_last')
  #a.add(debug_last)
  #BottomRule.is_prior_to(debug_last)
  #fastaformat.is_prior_to(debug_last)

  a.rehash
  return a
end