I have a file (a) like the follow:
('gi|290490588':0.0,'gi|290490602':0.00137,('gi|566163369':0.638271,('gi|302765619':0 .804737,(('gi|1026768672':0.692344,'gi|167999440':0.559082)[&label=1.0]:0.768415,(((((('gi|922359590':0.0,'gi|92 2359592':0.01216)[&label=1.0]:0.644957,(('gi|1026759849':0.279671,'gi|302813174':0.27607)[&label=0.969]:0.159941 ,('gi|168027479':0.522018,('gi|168039221':0.045808,('gi|168041596':0.077145, ...
I have to replace the gene ids (e.g. gi|290490588) with a more informative label. I have another file (b) with the ids-label correspondence.
key -------------|--value
gi|290490588 | foo
gi|290490602 | bar
I want to search file "a" with file "b" first column (key) and replace the ids in file "a" with the second column of file "b" (value).
Related
Imagine we have two list in two files,
file 1: contact_list_names.txt like:
Ali
James
Amir
Jones
Sarah
file 2 :contact_phones.txt like:
12344
43211
09876
67890
12309
I know that we can select all using gg then v then Shift + g to select all , but when you paste using p key its not pasting every number in front of its contact name ...
So how to paste the numbers in front of its related contact name ?
The problem using the clipboard to paste columns side by side is the type of selection of it, see here:
:echo getregtype('+')
if it returns a lowercase v, it means the type is characterwise.
if it returns an uppercase V, it means the type is linewise.
if it returns ^V{some number}, it means the type is blockwise, and the width of the block is {some number}.
But we can change it this way (making the clipboard register blockwise):
:call setreg('+',#+,'b')
Now if you try to paste a new column before or after the first one
you will succeed!
Here a function to get the content of the clipboard and paste after
the current column
fun! GiveItaNameYouWant()
call setreg('+',#+,'b')
normal gg
execute "normal! A \<esc>"
execute "normal! \"+p"
endfun
If you copy this function to the clipboard and load it into the memory just run:
:#+
Now put the cursor at the first column and run:
:call GiveItaNameYouWant()
Note: I am referring only to the clipboard register but you can also make these changes on the primary register selection "*", in the yank register "0" and default register '"' and a-z ones.
References: https://stackoverflow.com/a/48678100/2571881
I have file A 'Emails' with so many email , and file B 'Domain' with so many domain
Example File A 'Emails ':
ctv#ymail.com
kfi#aol.in
hi#axus.cc
0#gmail.com
igp#yahoo.com
encor#mail2.com
cjang#mail.com
vn#gmail.com
87#gmail.com
ee#maoyt.com
Example file B 'Domain'
#gmail.com
#yahoo.com
My expected result :
0#gmail.com
igp#yahoo.com
vn#gmail.com
87#gmail.com
is there a way to do with 2 file in emeditor .Thanks much
I would propose using the Join CSV function. #Abimanyu's regex method may work if you have less than 10 or so domains. More than that, it might take a while to process the data.
To prepare the document for joining, right click on the CSV/Sort toolbar and edit the User-defined separated format to use # as the delimiter.
Now on both file A and file B, change the CSV mode to User-defined separated. On the CSV/Sort toolbar, there is a button called "Join CSV".
Join CSV options:
Make sure the correct documents are selected
Key Column is the email domain columns
In the list at the bottom, select the output columns, which should be column 1 and 2 from file A
Press the Join Now button, change CSV mode to Normal mode and you will get an output which looks like this:
0#gmail.com
igp#yahoo.com
vn#gmail.com
87#gmail.com
May be this will be help to you :
Pattern : .*#gmail.com|.*#yahoo.com
Match groups:
Match 1
1. 0#gmail.com
Match 2
1. igp#yahoo.com
Match 3
1. vn#gmail.com
Match 4
1. 87#gmail.com
https://rubular.com/r/M3MVSoRj6qnSbl
The superadmin.txt file is in the form:
def
ghi
pqr
...etc
How would Perl read different users?
Will it be able to identify different text from superadmin.txt?
Here is the code:
#prelist = ();
#prelist = `cat ../cgi-bin/superadmin.txt`;
foreach $prename (#prelist) {
$prename =~s/\n//g ;
$superadminstaff{$prename} = "Y";
Well let's re write the code so it a) compiles, b) uses current best practice and c) doesn't fork out to cat
my #prelist = ();
my %superadminstaff = ();
open my $admin, '<', '../cgi-bin/superadmin.txt' or die "Can't open ../cgi-bin/superadmin.txt: $!\n";
chomp(#prelist = <$admin>);
#superadminstaff{#prelist} = ("Y") x #prelist;
So we have two variables #prelist and %superadminstaff, #prelist will hold each line of the file and %superadminstaff will end up keyed on each entry in the file.
Line 3 attempts to open the file, and if if can't will stop the script and print out a message explaining what went wrong.
Line 4 reads the file into #prelist and uses chomp to strip off the line endings. Note that chomp is used in preference to chop as the last line in the file my not have a line ending.
Line 5 uses some Perl magic called a hash slice to create entries in %superadminstaff for each element in#prelist and then uses the x operator to create a list containing as many Y elements as there are elements in #prelist this list of Ys is then assigned to the newly created elements in %superadminstaff.
So at the end of this code you now have %superadminstaff containing each entry of the file. However the order of the elements in the file will not be preserved and any duplicate entries in the file will be reduced to one entry in %superadminstaff.
I am trying to achieve this :
If B56 (on Summary page) matches value in column B (on "NPSSQL" page) then put text from NPSSQL column C (next to matching value) in to cell F56
if I use this code it gives me the incorrect value in cell F56 :
=IFERROR(INDEX(NPSSQL!C:C,MATCH(B56,NPSSQL!B:B,0)),NPSSQL!C:C)
I have added sample file - Sample File
in F56:
=Vlookup(B56,NPSSQL!C$2:D$500,2,0)
How can I modify a text file with R at a given position?
It's not a table but any file, for example an xml file.
For example to replace the content of line 122 from columns 7 (to 10) by the content of a variable, that is "3.14".
and update the file.
Imagine that line was
<name=0.32>
now should be
<name=3.14>
Or another option, maybe easier.
Look for all aparitions of occurences of "Variable=" and change the next 4 characters.
You would have to read in the entire file and then use string manipulation. E.g.,
f <- "file.xml"
x <- readLines(f)
x[122] <- paste0(substring(x[122], 1, 8), "3.14", substring(x[122], 13, nchar(x[122])))
writeLines(x, f)
I assume there is a command-line tool that would be better suited to this.