@@ -5845,7 +5845,7 @@ sub bcprintmedia {
5845
5845
[" media" ,1,undef ," Name of the media formulation to be printed." ],
5846
5846
],[@Data ]," print Model SEED media formulation" );
5847
5847
my $media = $self -> figmodel()-> database()-> get_moose_object(" media" ,{id => $args -> {media }});
5848
- ModelSEED::globals::PRINTOBJECT({ data => $media -> pack (), filename => $ self-> ws()-> directory().$args -> {media }." .media" } );
5848
+ ModelSEED::globals::PRINTFILE( $ self-> ws()-> directory().$args -> {media }." .media" , $media -> print () );
5849
5849
return " Successfully printed media '" .$args -> {media }." ' to file '" . $self -> ws()-> directory().$args -> {media }." .media'!" ;
5850
5850
}
5851
5851
@@ -5860,31 +5860,18 @@ This function is used to create or alter a media condition in the Model SEED dat
5860
5860
sub bcloadmedia {
5861
5861
my ($self ,@Data ) = @_ ;
5862
5862
my $args = $self -> check([
5863
- [" name" ,1,undef ," The name of the media formulation being created or altered." ],
5864
- [" filename" ,0,undef ," The full path and name to access a file specifying the media components. [[Example media file]]." ],
5865
- [" compounds" ,0,undef ," As an alternative to specifying a filename, you can specify a ';' delimited list of the compound proposed to be present in the media. Either compound names or cpd##### ids must be supplied." ],
5866
- [" public" ,0,1," Set directory in which FBA problem output files will be stored." ],
5863
+ [" media" ,1,undef ," The name of the media formulation being created or altered." ],
5864
+ [" public" ,0,0," Set directory in which FBA problem output files will be stored." ],
5867
5865
[" owner" ,0,($self -> figmodel()-> user())," Login of the user account who will own this media condition." ],
5868
5866
[" overwrite" ,0,0," If you set this parameter to '1', any existing media with the same input name will be overwritten." ]
5869
5867
],[@Data ]," Creates (or alters) a media condition in the Model SEED database" );
5870
- if (defined ($args -> {compounds })) {
5871
- $args -> {compounds } = $self -> figmodel()-> processIDList({
5872
- objectType => " compound" ,
5873
- delimiter => " ;" ,
5874
- column => " id" ,
5875
- parameters => undef ,
5876
- input => $args -> {compounds }
5877
- });
5878
- }
5879
- my $media = $self -> figmodel()-> get_media()-> create({
5880
- id => $args -> {name },
5881
- filename => $args -> {filename },
5882
- compounds => $args -> {compounds },
5883
- public => $args -> {public },
5884
- owner => $args -> {owner },
5885
- overwrite => $args -> {overwrite }
5886
- });
5887
- print " Media successfully created!\n " ;
5868
+ my $media ;
5869
+ if (!-e $self -> ws()-> directory().$args -> {media }) {
5870
+ ModelSEED::globals::ERROR(" Could not find media file " .$self -> ws()-> directory().$args -> {media });
5871
+ }
5872
+ $media = ModelSEED::MooseDB::media-> new({db => $self -> figmodel()-> database(),filedata => ModelSEED::globals::LOADFILE($self -> ws()-> directory().$args -> {media })});
5873
+ $media -> syncWithPPODB({overwrite => $args -> {overwrite }});
5874
+ return " Successfully loaded media " .$args -> {media }." to database as " .$media -> id();
5888
5875
}
5889
5876
5890
5877
=head
@@ -6135,37 +6122,38 @@ Prints the specified model(s) in SBML format.
6135
6122
sub mdlprintsbml {
6136
6123
my ($self ,@Data ) = @_ ;
6137
6124
my $args = $self -> check([
6138
- [" model" ,1,undef ," A ',' delimited list of the models in the Model SEED for which SBML files should be printed." ],
6125
+ [" model" ,1,undef ," Model for which SBML files should be printed." ],
6126
+ [" media" ,0," Complete" ," ID of a media condition or media file for which SBML should be printed" ],
6139
6127
],[@Data ]," prints model(s) in SBML format" );
6140
- my $results = $self -> figmodel()-> processIDList({
6128
+ my $models = $self -> figmodel()-> processIDList({
6141
6129
objectType => " model" ,
6142
- delimiter => " , " ,
6130
+ delimiter => " ; " ,
6143
6131
column => " id" ,
6144
6132
parameters => {},
6145
6133
input => $args -> {" model" }
6146
6134
});
6147
- my $message ;
6148
- if (@{$results } == 1 || $args -> {usequeue } == 0) {
6149
- for (my $i =0;$i < @{$results }; $i ++) {
6150
- print " Now processing " .$results -> [$i ]." \n " ;
6151
- my $mdl = $self -> figmodel()-> get_model($results -> [$i ]);
6152
- if (!defined ($mdl )) {
6153
- ModelSEED::globals::WARNING(" Model not valid " .$args -> {model });
6154
- $message .= " SBML printing failed for model " .$results -> [$i ]." . Model not valid!\n " ;
6155
- } else {
6156
- my $sbml = $mdl -> PrintSBMLFile();
6157
- $self -> db()-> print_array_to_file($self -> ws()-> directory().$results -> [$i ]." .xml" ,$sbml );
6158
- $message .= " SBML printing succeeded for model " .$results -> [$i ]." !\n File printed to " .$self -> ws()-> directory().$results -> [$i ]." .xml" ." !" ;
6159
- }
6160
- }
6161
- } else {
6162
- for (my $i =0; $i < @{$results }; $i ++) {
6163
- $self -> figmodel()-> mdlprintsbml({
6164
- command => " mdlprintsbml?" .$results -> [$i ],
6165
- user => $self -> figmodel()-> user()." :" .$self -> ws()-> id()." :" .$self -> ws()-> path(),
6166
- queue => $args -> {queue }
6167
- });
6135
+ if ($args -> {media } =~ m /\. media$ / ) {
6136
+ if (!-e $self -> ws()-> directory().$args -> {media }) {
6137
+ ModelSEED::globals::ERROR(" Media file " .$self -> ws()-> directory().$args -> {media }." not found" );
6168
6138
}
6139
+ $args -> {media } = ModelSEED::MooseDB::media-> new({
6140
+ filename => $args -> {media }
6141
+ });
6142
+ }
6143
+ my $message ;
6144
+ for (my $i =0; $i < @{$models };$i ++) {
6145
+ print " Now loading model " .$results -> [$i ]." \n " ;
6146
+ my $mdl = $self -> figmodel()-> get_model($results -> [$i ]);
6147
+ if (!defined ($mdl )) {
6148
+ ModelSEED::globals::WARNING(" Model not valid " .$args -> {model });
6149
+ $message .= " SBML printing failed for model " .$results -> [$i ]." . Model not valid!\n " ;
6150
+ next ;
6151
+ }
6152
+ my $sbml = $mdl -> PrintSBMLFile({
6153
+ media => $args -> {media }
6154
+ });
6155
+ ModelSEED::globals::PRINTFILE($self -> ws()-> directory().$results -> [$i ]." .xml" ,$sbml );
6156
+ $message .= " SBML printing succeeded for model " .$results -> [$i ]." !\n File printed to " .$self -> ws()-> directory().$results -> [$i ]." .xml" ." !" ;
6169
6157
}
6170
6158
return $message ;
6171
6159
}
@@ -6344,6 +6332,40 @@ sub mdlloadmodel {
6344
6332
print " Successfully imported " .$args -> {" name" }." into Model SEED as " .$modelObj -> id()." !\n\n " ;
6345
6333
}
6346
6334
6335
+ =head
6336
+ =CATEGORY
6337
+ Metabolic Model Operations
6338
+ =DESCRIPTION
6339
+ This function changes the drain fluxes associated with a model.
6340
+ =EXAMPLE
6341
+ ./mdlchangedrains -'''model''' "iJR904" -'''drains''' "cpd15302[c]" -'''inputs''' "cpd15302[c]"
6342
+ =cut
6343
+ sub mdlchangedrains {
6344
+ my ($self ,@Data ) = @_ ;
6345
+ my $args = $self -> check([
6346
+ [" model" ,1,undef ," ID of the model the drains are to be added to" ],
6347
+ [" drains" ,0,undef ," \" ;\" delimited list of compounds for which drains should be added" ],
6348
+ [" inputs" ,0,undef ," \" ;\" delimited list of compounds for which inputs should be added" ],
6349
+ ],[@Data ]," change drain fluxes associated with model" );
6350
+ $args -> {drains } = ModelSEED::globals::PROCESSIDLIST({
6351
+ input => $args -> {drains },
6352
+ validation => " ^cpd\\ d+\\ [*\\ w*\\ ]*$"
6353
+ });
6354
+ $args ->{inputs} = ModelSEED::globals::PROCESSIDLIST({
6355
+ input => $args ->{inputs},
6356
+ validation => " ^cpd\\d+\\[*\\w*\\]*$"
6357
+ });
6358
+ my $model = $self -> figmodel()-> get_model($args -> {model });
6359
+ if (!defined ($model )) {
6360
+ ModelSEED::globals::ERROR(" Model not valid " .$args -> {model });
6361
+ }
6362
+ my $string = $model -> changeDrains({
6363
+ drains => $args -> {drains },
6364
+ inputs => $args -> {inputs },
6365
+ })
6366
+ return " Successfully adjusted the drain fluxes associated with model " .$args -> {model }." to " .$string ;
6367
+ }
6368
+
6347
6369
=head
6348
6370
=CATEGORY
6349
6371
Metabolic Model Operations
0 commit comments