How to check this? :(
Posted by revtopo (revtopo), 21 June 2007Hi there,
Am trying to write a code in bioperl to get the data from a database server corresponding to the ids.
Here is the snippet of my code:
-db => 'uniprot', #going to get records from this database
-AccNumbers => \@array, # contains the list of ids
-file => './topo_protein.dbi'# writes in this file.
I have to get this records stored in the file ./topo_protein.dbi' and parse them to those am in need of. then have to load those to the database using mysql. I have written a code to do all these in a single streatch.
~ this does the parsing and loading them in the database:
my $acc = $seq->accession_number;
my $name = $seq->desc();
my $sequence = $seq->seq;
my $length = $seq->length();# parsing the recors to have these attributes in my database.
my $query= $connect->prepare("insert into topo_interpro.PROTEIN_DBI(Accession_id,Protein_name,Sequence,Sequence_len) values(?,?,?,?)");#to insert rows into the database. in the table name PROTEIN_DBI.
what I actually I wish to do is if I have the records already in the fiel that I have mentioned then it has to continue with the rest of my program like parsing them for the stuufs I need and loading them to the database.
could any one help me out of this.
Posted by admin (Graham Ellis), 22 June 2007Hi ... I'm afraid I don't fully undertstand the question; I think you're trying to insert only records which don't already exist into a database rather than putiing the whole lot of them in. Is that the case? If so, you'll need to do a separate check with each record to see if it's there OR to do a replace if you don't mind the whole of the record being replaced.
If you can come back with a more specific descritpion, I might be able to offer further and more specific advise.
Posted by revtopo (revtopo), 22 June 2007Hi Graham,
The file contains the complete records of the ids. These record are got from uniprot (a global database) using the ids. I will filter them into 4 attributes I need. What should be done is to read the file that I have and if they have records then it should say something like " you have got records in it" or else it has to proceed with writing in the file and continue with the further process. If it has records then it has to skip just the writing into file but should proceed with ohter steps like parsing and loading them in the database. There is no need to check with the database( that i produce) we have to check with the file only.
Am i clear in my point now?
My point in doing that:
And what I think now is the ids I mention are unique which pulls out the records from the database(uniprot a global database). So will it make easy to do grep in file with ids. These ids are contained in another file. So we can use that file and check with the ids.
Posted by admin (Graham Ellis), 22 June 2007It's seeming very much like a project specification than a simple question I can answer in a few limes, so I wonder if a forum is really the best medium to help sort you out. I fear painfully frustrating progress for both of us as we take steps forward and I would encourage you to have a look at other alternatives such as our perl courses - or if it doesn't need all of that, perhaps pop over and stay at the hotel and I'll spend a few hours with you - no charge - in the evening?
Having said that, I note that you're also posted a related question on "grep" which I have just answered. And your question there does confirm thaty you could really benefit from our training.
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho