Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iGE3
tools
Commits
364a95cf
Commit
364a95cf
authored
Jun 12, 2015
by
Natacha Civic
Browse files
Options
Downloads
Patches
Plain Diff
match lines from file (annotation)
parent
9952442d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
match_fast.pl
+59
-0
59 additions, 0 deletions
match_fast.pl
with
59 additions
and
0 deletions
match_fast.pl
0 → 100644
+
59
−
0
View file @
364a95cf
#!/usr/bin/env perl
use
strict
;
#
# 1. Load key
#
my
$keyfile
=
shift
@ARGV
;
defined
$keyfile
or
die
"
Please give a key file !
\n
";
print
STDERR
"
Load keys from
$keyfile
\n
";
my
@keys
;
my
$rx
=
qr/Locus_[[:digit:]]+_Transcript_[[:digit:]]+_[[:digit:]]+_/
;;
{
open
my
$f
,
"
<
",
$keyfile
or
die
"
open error
$keyfile
";
@keys
=
map
{
s{[\n\r]+$}{}g
;
$_
}
<
$f
>
;
close
$f
;
print
STDERR
"
$#keys keys in file
\n
";
print
STDERR
"
Build regex
\n
";
}
my
%reverse
=
map
{
$_
=>
1
}
@keys
;
#
# 2. Scan input for lines matching the keys
#
print
STDERR
"
Scan input
${ARGV
[0]
}
...
\n
";
my
$m
=
0
;
my
$l
=
0
;
my
$p
=
'';
my
%matches
;
while
(
<>
)
{
if
(
$_
=~
/Locus_[[:digit:]]+_Transcript_[[:digit:]]+_[[:digit:]]+_/
)
{
next
if
(
!
exists
$reverse
{
$&
}
);
# .. do not print matching lines but store them into hash
$matches
{
$&
}
=
$_
;
++
$m
;
print
STDERR
"
\r
${p}
Line
$l
Found
$m
/ $#keys matches...
";
}
}
continue
{
if
(((
++
$l
)
&
127
)
==
0
)
{
$p
=
int
(
tell
()
*
100
/
(
-
s $ARGV)) . '% - '
if( -e $ARGV);
print STDERR "\r$
{
p
}
Line
$l
"
;
}
}
#
# 3. for each key either printing matching line or 'NOT FOUND'
#
print STDERR
"
\
nWrite
results
...\
n
"
;
foreach (
@keys
) {
print
$_
.
":
\
t
"
. (exists
$matches
{
$_
} ?
$matches
{
$_
} : 'NOT FOUND!') .
"
\
n
"
;
}
print STDERR
"
Done
\
n
"
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment