Jump to content


Photo

Improvements?


  • Please log in to reply
6 replies to this topic

#1 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 09 June 2006 - 08:22 PM

if ($het[0] == $het[0]) { 
$command = "c at $file |grep ^HETATM |grep ' $het[0] ' > ${id}_$het[0].pdb";
s ystem($command, $output);

$new file = "${id}_$het[0].pdb";
$input = f ile($newfile); // read file into an array
$fp = f open($newfile,'w'); // open output file for write

foreach($input as $line) {

if ($line[17]=='H') {  
    if ($line[18]=='O') { 
        if ($line[19]=='H') {
      $line[72] = 'W'; //the first character of the string is at position 0
      $line[73] = 'A';
      $line[74] = 'T';
      $line[75] = '1';

      $line[17] = 'T';
      $line[18] = 'I';
      $line[19] = 'P';
      $line[20] = '3';

      $line[13] = 'O';
      $line[14] = 'H';
      $line[15] = '2';

      $line[0] = 'A';
      $line[1] = 'T';
      $line[2] = 'O';
      $line[3] = 'M';
      $line[4] = ' ';
      $line[5] = ' ';

}}}

else {
      $line[0] = 'A';
      $line[1] = 'T';
      $line[2] = 'O';
      $line[3] = 'M';
      $line[4] = ' ';
      $line[5] = ' ';

      $line[72] = 'H'; 
      $line[73] = 'E';
      $line[74] = 'T';
      $line[75] = '1';

}


f write($fp,$line);
}


f close($fp);

echo "${id}_$het[0].pdb<br>";
}


The problem is how do i make ($het[0] == $het[0]) dynamic?
$het[0] is the result of a checkbutton from the prev. page.

Lets say
het[0] = AC9
het[1]=HOH

I want the script to perform certain instructions dynamically.

System commands and file options without spaces... ofcourse.

#2 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 09 June 2006 - 08:26 PM

checkboxes aren't sent as data unless they're checked. So all the checkbox data you receive will contain the values of the checkboxes that were ticked but will not contain any entries for checkboxes that were ignored
[table]



Don't worry, the printer fairies will sort it out.

#3 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 09 June 2006 - 08:33 PM

[!--quoteo(post=382039:date=Jun 9 2006, 04:26 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:26 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
checkboxes aren't sent as data unless they're checked. So all the checkbox data you receive will contain the values of the checkboxes that were ticked but will not contain any entries for checkboxes that were ignored
[/quote]

I know that.

Lets say there are 10 checkboxes, all clicked. How do i make the script perfrom instructions for all the boxes.. writing the code for just one? The script should use the Value of the checkboxes to make changes.

#4 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 09 June 2006 - 08:46 PM

$boxes = $_REQUEST['check'];
for($i = 0; $i < count($boxes); $i++)
{
// Do whatever to $boxes[$i]
}
// You could use this if you didn't need to edit them using $i
foreach($boxes as $key => $val)
{
// Code
}
// Or if you don't need the key at all and just the value:
foreach($boxes as $box)
{
// Code
}

[table]



Don't worry, the printer fairies will sort it out.

#5 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 09 June 2006 - 08:52 PM

[!--quoteo(post=382050:date=Jun 9 2006, 04:46 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:46 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
$boxes = $_REQUEST['check'];
for($i = 0; $i < count($boxes); $i++)
{
// Do whatever to $boxes[$i]
}
// You could use this if you didn't need to edit them using $i
foreach($boxes as $key => $val)
{
// Code
}
// Or if you don't need the key at all and just the value:
foreach($boxes as $box)
{
// Code
}
[/quote]

when i do this, How do i define individual box?
for example,
I need to name the file as
atom_(check box value).pdb.
How do i define the check box value for different boxes?
If i define it a atom_$boxes.pdb
it comes up as atom_Array.pdb



#6 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 09 June 2006 - 08:55 PM

foreach($boxes as $box)
{
$fname = 'atom_' . $box . '.pdb';
}

[table]



Don't worry, the printer fairies will sort it out.

#7 vidyashankara

vidyashankara
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 09 June 2006 - 09:05 PM

[!--quoteo(post=382057:date=Jun 9 2006, 04:55 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:55 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
foreach($boxes as $box)
{
$fname = 'atom_' . $box . '.pdb';
}
[/quote]

Perfect! works like a charm!!!

Thanks a lot :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users