Jump to content

Improvements?


vidyashankara

Recommended Posts

[code]
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>";
}

[/code]

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[!--quoteo(post=382039:date=Jun 9 2006, 04:26 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:26 PM) [snapback]382039[/snapback][/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.
Link to comment
Share on other sites

[code]$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
}[/code]
Link to comment
Share on other sites

[!--quoteo(post=382050:date=Jun 9 2006, 04:46 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 04:46 PM) [snapback]382050[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]$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
}[/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

Link to comment
Share on other sites

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

Perfect! works like a charm!!!

Thanks a lot :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.