in reply to Replace table values from text database

I do not think it is illustrative enough in its current form

Perhaps, but I would say the main cause of that is the lack of sample data and expected output, not the node title. My own eye was drawn to the unescaped dot in your regexp, and a couple of other small things, but it's impossible to tell whether they are affecting your script, because we can't see any data. So please post a small sample of the input data and the expected output.

Also, I would suggest using a hash, loop, and substitution inside your program rather than shelling out to call a Perl one-liner for each line you are comparing; just seems cleaner, not to mention more efficient and safer.


The way forward always starts with a minimal test.
  • Comment on Re: Replace table values from text database

Replies are listed 'Best First'.
Re^2: Replace table values from text database
by Alfumao (Initiate) on Mar 14, 2016 at 14:12 UTC
    How can I upload a sample of the test files to this thread?

        I hope this helps

        #Database of table names and new names Aspergillus_clavatus_1 XP_001276684.1 pectate lyase, putative [Aspe +rgillus clavatus NRRL 1] Aspergillus_fumigatus_2 XP_001276694.1 conserved hypothetical prote +in [Aspergillus fumigatus NRRL 1] Aspergillus_flavus_3 XP_001276726.1 tyrosinase central domain prote +in [Aspergillus flavus NRRL 1] Aspergillus_terreus_4 XP_001276738.1 endoglucanase, putative [Asper +gillus terreus NRRL 1] #Lines of the table to be renamed Aspergillus_clavatus_1 Aspergillus_flavus_198 Aspergillus_terreu +s_166 Aspergillus_fumigatus_2 Aspergillus_clavatus_1 Aspergillus_flavus_3 Aspergillus_terreus_ +4 Aspergillus_fumigatus_2 Aspergillus_clavatus_3 Aspergillus_flavus_198 Aspergillus_terreu +_166 Aspergillus_fumigatus_16 #Expected result (See that in some cases there's no replacement to be +done, if the ID is not present in the names "database" file XP_001276684.1 pectate lyase, putative [Aspergillus clavatus NRRL 1] + Aspergillus_flavus_198 Aspergillus_terreus_166 XP_001276694.1 + conserved hypothetical protein [Aspergillus fumigatus NRRL 1] XP_001276684.1 pectate lyase, putative [Aspergillus clavatus NRRL 1] + XP_001276726.1 tyrosinase central domain protein [Aspergillus flavu +s NRRL 1] XP_001276738.1 endoglucanase, putative [Aspergillus terr +eus NRRL 1] XP_001276694.1 conserved hypothetical protein [Aspergi +llus fumigatus NRRL 1] Aspergillus_clavatus_3 Aspergillus_flavus_198 Aspergillus_terreu +_166 Aspergillus_fumigatus_16