Loading ...
Sorry, an error occurred while loading the content.

Perl ... ??

Expand Messages
  • Azzam G
    hi all, is there anyone here that know Perl Language ?? i found this code under the name of xml2db i found another one also in Python Language ?? i hope some
    Message 1 of 1 , Jan 14, 2003
    • 0 Attachment
      hi all,

      is there anyone here that know Perl Language ??

      i found this code under the name of xml2db
      i found another one also in Python Language ?? i hope some one can give a
      brief note on whats happening inside this file please.


      My Best Regards,

      Azzam




      _________________________________________________________________
      The new MSN 8: smart spam protection and 2 months FREE*
      http://join.msn.com/?page=features/junkmail

      ----------

      #!/usr/local/bin/perl -w
      #
      # xml2db.pl
      # comments: cjm@...
      #
      # use the -help switch to get valid flags

      # usage: xml2db.pl [-html] [-d dbname] xml_file.xml

      use strict;
      use lib $ENV{FLYBASE_MODULE_PATH};
      use lib $ENV{BIOPERL_MODULE_PATH}; # not required yet

      use GeneralUtils::MiscUtils qw(interpret_command_line_flags dd);
      use GxAdapters::Dataflow qw(xml2db feature_types2db);
      use GxAdapters::ConnectionManager qw(get_handle close_handle);
      use GxAdapters::GxSeqFeature;
      use GxAdapters::GxSeq;
      use BioModel::Query;

      my $argh = interpret_command_line_flags(\@ARGV, {'dump'=>0, d=>1,
      commit=>0, autocommit=>0,
      infmt=>1, seqname=>1,
      query=>1, analysis_only=>0,
      jamdir=>1, fban=>1,
      noupdates=>0,
      seed=>1});
      $ENV{GADB_SUPPRESS_RESIDUES} = 0;
      $ENV{WEAVE_SEQ} = 1;
      $ENV{GADB_SCHEMA2} = 1;


      if ($argh->{autocommit}) {
      $argh->{commit} = 1;
      }
      my $dbh = get_handle($argh->{d} || "gadb");
      feature_types2db(-dbh=>$dbh, -clear=>1);

      while (my $fn = shift @ARGV) {
      GxAdapters::GxSeq->clear_memory_cache($dbh);
      GxAdapters::GxSeqFeature->clear_memory_cache($dbh);
      my $infmt = $argh->{infmt} || "";
      my $seqname = $argh->{seqname} || $fn;
      $seqname =~ s/\.xml//;
      $seqname =~ s/_12X_2//;
      my @a= split(/\//, $seqname);
      $seqname = $a[-1];

      my $errors_l =
      xml2db(-dbh=>$dbh,
      -file=>$fn,
      -fmt=>$infmt,
      -seqname=>$seqname,
      -commit=>$argh->{autocommit},
      -options=>$argh);

      print "Done!";

      if (@{$errors_l||[]}) {
      print "\nERRORS:\n";
      map {print " * $_\n\n"} @$errors_l;
      }

      if ($argh->{query}) {
      my $query = BioModel::Query->new();
      $query->add_clause(BioModel::QueryClause->new(-text=>$argh->{query}));
      print "Query\n-----\n".$query->as_string."\n\n";

      my $ann = GxAdapters::GxAnnotation->select_obj($dbh,
      {query=>$query},
      ["id", "perlobj"]);
      # $ann->restore;
      print $ann->to_xml;
      # print $ann->to_table->as_text;
      }

      if ($argh->{fban}) {
      my $ann = GxAdapters::GxAnnotation->select_obj($dbh,
      {where=>"primary_acc = '".$argh->{fban}."'"},
      ["id", "perlobj"]);
      # dd($ann);
      print $ann->to_xml;
      # print $ann->to_table->as_text;
      }

      if ($argh->{commit}) {
      print "\nCOMMITTING\n";
      $dbh->commit;
      }
      else {
      print "\ROLLBACK\n";
      $dbh->rollback;
      }
      }

      close_handle($dbh);
      print "End of xml2db.pl";



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.