Created
August 22, 2023 03:44
-
-
Save meso-cacase/7a287171a6b364b5b487bdb55c66b251 to your computer and use it in GitHub Desktop.
RefSeq IDの順番にソート
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# RefSeqのIDを順番に並べ替える | |
# | |
# NM_123456.7 | |
# NM_123456789.12 | |
# | |
# (1:アルファベット部)_(2:整数部).(3:バージョン番号) | |
# 1 -> 2 -> 3 の優先順位でソートする | |
# | |
# 2023-08-21 Yuki Naito (@meso_cacase) | |
use warnings ; | |
use strict ; | |
print sort compare_refid <> ; | |
exit ; | |
sub compare_refid { | |
my ($a_moltype, $a_id, $a_ver) = ($a =~ /([A-Z]+)_(\d+)(\.(\d+))?/) ? ($1, $2, $4) : () ; | |
my ($b_moltype, $b_id, $b_ver) = ($b =~ /([A-Z]+)_(\d+)(\.(\d+))?/) ? ($1, $2, $4) : () ; | |
return $a_moltype cmp $b_moltype || $a_id <=> $b_id || $a_ver <=> $b_ver ; | |
} ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment