473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Extrcting Data From A File!!!!!!!!!!

2
HI ,I am new to this community.I have a problem ,I need to extract a particular set of data from a PDB file.

ATOM 58 N LYS A 4 1.056 -6.780 1.309 1.00 0.00 N
ATOM 80 C LEU A 5 -1.728 -3.541 2.589 1.00 0.00 N
ATOM 99 N VAL A 6 -0.493 -1.237 4.786 1.00 0.00 N
ATOM 115 N ILE A 7 -1.369 1.593 6.323 1.00 0.00 N
ATOM 134 N ASN A 8 -0.003 4.422 7.554 1.00 0.00 N
ATOM 148 CA GLY A 9 -0.870 7.244 8.066 1.00 0.00 N
ATOM 155 N LYS A 10 -1.156 10.860 8.465 1.00 0.00 N
ATOM 177 N THR A 11 -3.682 11.632 9.106 1.00 0.00 N
ATOM 191 CA LEU A 12 -5.325 9.585 8.210 1.00 0.00 N


this is a example of a my file.At first I needed to extract the lines which have CA at the 3rd position.I used this script(windows XP)
code:

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl -w
  2. open(FILE,"<2OED.pdb") or die "cant open file:$!\n";
  3. open(FILE1,">a.txt") or die "cant open file:$!\n";
  4. @pro=<FILE>;
  5. @atom=grep{$_=~/^ATOM\s+/}@pro;
  6. @atoms1=grep{$_=~/^ATOM\s+\d+\s+CA\s+/}@atom;
  7. print FILE1"@atoms1";
  8. close FILE;
  9. close FILE1;
  10.  
This is working finely.But now I need to extract the underlined portion or digits from the file and print them to another.(note:=the digits are not originally underlined,I used that only for indicating)

plz help.
Nov 17 '07 #1
1 1318
numberwhun
3,509 Expert Mod 2GB
HI ,I am new to this community.I have a problem ,I need to extract a particular set of data from a PDB file.

ATOM 58 N LYS A 4 1.056 -6.780 1.309 1.00 0.00 N
ATOM 80 C LEU A 5 -1.728 -3.541 2.589 1.00 0.00 N
ATOM 99 N VAL A 6 -0.493 -1.237 4.786 1.00 0.00 N
ATOM 115 N ILE A 7 -1.369 1.593 6.323 1.00 0.00 N
ATOM 134 N ASN A 8 -0.003 4.422 7.554 1.00 0.00 N
ATOM 148 CA GLY A 9 -0.870 7.244 8.066 1.00 0.00 N
ATOM 155 N LYS A 10 -1.156 10.860 8.465 1.00 0.00 N
ATOM 177 N THR A 11 -3.682 11.632 9.106 1.00 0.00 N
ATOM 191 CA LEU A 12 -5.325 9.585 8.210 1.00 0.00 N


this is a example of a my file.At first I needed to extract the lines which have CA at the 3rd position.I used this script(windows XP)
code:

Expand|Select|Wrap|Line Numbers
  1. #!usr/bin/perl -w
  2. open(FILE,"<2OED.pdb") or die "cant open file:$!\n";
  3. open(FILE1,">a.txt") or die "cant open file:$!\n";
  4. @pro=<FILE>;
  5. @atom=grep{$_=~/^ATOM\s+/}@pro;
  6. @atoms1=grep{$_=~/^ATOM\s+\d+\s+CA\s+/}@atom;
  7. print FILE1"@atoms1";
  8. close FILE;
  9. close FILE1;
  10.  
This is working finely.But now I need to extract the underlined portion or digits from the file and print them to another.(note:=the digits are not originally underlined,I used that only for indicating)

plz help.
First off, before I get to your question, I understand that you are new to the forum, but that does not stop you from reading the sticky message at the top of the forum. If you had read it, you would have seen that code tags are required. I have added them for you this time, but please be sure and use them next time.

As for your data, I would use the split() function to split each line of data and grab the elements that you want.

Regards,

Jeff
Nov 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Domenico Discepola | last post by:
Hello all. Before my arrival at my current employer, our consultants physically set up our MSSQL 7 server as follows: drive c: contains the mssql engine drive d: contains the transaction log...
0
by: Auday Alwash | last post by:
Hi, A month ago, we were running out of disk space on a drive that stores the data file for a SQL Server 7 database. So I added a new drive and created a new data file on the primary filegroup...
7
by: Bob | last post by:
Hi, I am trying to use BULK INSERT with format file. All of our data has few bytes of header in the data file which I would like to skip before doing BULK INSERT. Is it possible to write...
12
by: Steven Bethard | last post by:
Ok, so I have a module that is basically a Python wrapper around a big lookup table stored in a text file. The module needs to provide a few functions:: get_stem(word, pos, default=None)...
2
by: nepdae | last post by:
Please forgive me, this is a long one. My 11-user Access 2000 database is having recurring corruption problems. The symptoms include the following: 1) corrupted fields in recently created or...
2
by: AB | last post by:
Hi to all, I have a problem about a importation of a file *.csv with SQL Server, through a bulk insert, called in a store procedure that a c# sw calls. This is the description of the error:...
10
by: HardySpicer | last post by:
I have a cvs data file orbit.csv and found this code. function ReadFile() { var fso, f1, ts, s; var ForReading = 1; fso = new ActiveXObject("Scripting.FileSystemObject"); f =...
2
by: phpnoob | last post by:
I have a php script that processes a form and then posts the user input to a data file on the server in a comma delimited format. For simplicity call the file "data.csv." The script is working...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
0
by: blehhhhh | last post by:
hi guys, So i have this java assignment where I have to create an employee class with given datatypes and have accessor methods in it. Along with that i have to create a text file(data file) with...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.